public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-platforms][PATCH 1/2] ManageabilityPkg: Add Manageability IPMI helper Library
@ 2023-05-09  7:56 Chang, Abner
  2023-05-09  7:56 ` [edk2-platforms][PATCH 2/2] ManageabilityPkg/ManageabilityTransportKcsLib: Add debug message of IPMI KCS Completion Code Chang, Abner
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Chang, Abner @ 2023-05-09  7:56 UTC (permalink / raw)
  To: devel; +Cc: Isaac Oram, Abdul Lateef Attar, Nickle Wang, Tinh Nguyen

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

Add IPMI helper library to print debug message
of IPMI Completion Code in human readable string
and return the transport interface additional
status.

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: Tinh Nguyen <tinhnguyen@os.amperecomputing.com>
---
 .../BaseManageabilityTransportHelper.inf      |  1 +
 .../Library/ManageabilityTransportHelperLib.h | 24 +++++++
 .../Library/ManageabilityTransportIpmiLib.h   | 13 +++-
 .../Library/ManageabilityTransportLib.h       | 11 +--
 .../BaseManageabilityTransportIpmiHelper.c    | 70 +++++++++++++++++++
 5 files changed, 112 insertions(+), 7 deletions(-)
 create mode 100644 Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportIpmiHelper.c

diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.inf b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.inf
index c9e5eaef60..0936449fda 100644
--- a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.inf
+++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.inf
@@ -21,6 +21,7 @@
 
 [Sources]
   BaseManageabilityTransportHelper.c
+  BaseManageabilityTransportIpmiHelper.c
 
 [LibraryClasses]
   BaseMemoryLib
diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelperLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelperLib.h
index c2c98d6c2d..11a1bd0521 100644
--- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelperLib.h
+++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelperLib.h
@@ -187,4 +187,28 @@ HelperManageabilityDebugPrint (
   ...
   );
 
+///
+/// IPMI Helper Functions.
+///
+
+/**
+  This function returns a human readable string of IPMI KCS Completion Code
+  and returns the corresponding additional status of transport interface.
+
+  @param [in]  CompletionCode     The Completion Code returned from KCS.
+  @param [out] CompletionCodeStr  Human readable string of IPMI Completion Code.
+  @param [out] AdditionalStatus   Return the addtional status.
+
+  @retval  EFI_SUCCESS            The information of Completion Code is returned.
+  @retval  EFI_NOT_FOUND          No information of Completion Code is returned.
+  @retval  EFI_INVALID_PARAMETER  The given parameter is incorrect.
+
+**/
+EFI_STATUS
+IpmiHelperCheckCompletionCode (
+  IN   UINT8                                      CompletionCode,
+  OUT  CHAR16                                     **CompletionCodeStr,
+  OUT  MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS  *AdditionalStatus
+  );
+
 #endif
diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIpmiLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIpmiLib.h
index 1628255a6a..6d136e460f 100644
--- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIpmiLib.h
+++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIpmiLib.h
@@ -16,9 +16,18 @@
 /// the payload.
 ///
 typedef struct {
-  UINT8    Lun:2;
-  UINT8    NetFn:6;
+  UINT8    Lun   : 2;
+  UINT8    NetFn : 6;
   UINT8    Command;
 } MANAGEABILITY_IPMI_TRANSPORT_HEADER;
 
+///
+/// The IPMI Completion Code mapping.
+///
+typedef struct {
+  UINT8                                        CompletionCode;
+  CHAR16                                       *CompletionCodeString;
+  MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS    AdditionalStatus;
+} MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING;
+
 #endif
diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h
index 04072aee89..f423a1ed44 100644
--- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h
+++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h
@@ -61,11 +61,12 @@ typedef union {
 /// Additional transport interface status.
 ///
 typedef UINT32 MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS;
-#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERRORS      0x00000000
-#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_ERROR          0x00000001
-#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_READ   0x00000002
-#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_WRITE  0x00000004
-#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NOT_AVAILABLE  0xffffffff
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERRORS        0x00000000
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_ERROR            0x00000001
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_READ     0x00000002
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_WRITE    0x00000004
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_INVALID_COMMAND  0x00000008
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NOT_AVAILABLE    0xffffffff
 
 ///
 /// Additional transport interface features.
diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportIpmiHelper.c b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportIpmiHelper.c
new file mode 100644
index 0000000000..8710cafc99
--- /dev/null
+++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportIpmiHelper.c
@@ -0,0 +1,70 @@
+/** @file
+  Null instance of Manageability IPMI Helper Library
+
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Uefi.h>
+#include <Library/DebugLib.h>
+#include <Library/ManageabilityTransportIpmiLib.h>
+
+#include <IndustryStandard/Ipmi.h>
+
+//
+// BaseManageabilityTransportHelper is used by PEI, DXE and SMM.
+// Make sure the global variables added here should be unchangeable.
+//
+MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING  IpmiCompletionCodeMapping[] = {
+  { IPMI_COMP_CODE_NORMAL,          L"IPMI Completion Code - Normal",          MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERRORS       },
+  { IPMI_COMP_CODE_NODE_BUSY,       L"IPMI Completion Code - Busy",            MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_READ    },
+  { IPMI_COMP_CODE_INVALID_COMMAND, L"IPMI Completion Code - Invalid command", MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_INVALID_COMMAND }
+};
+
+UINT8  IpmiCompletionCodeMappingEntries = sizeof (IpmiCompletionCodeMapping) / sizeof (MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING);
+
+///
+/// IPMI Helper Functions.
+///
+
+/**
+  This function returns a human readable string of IPMI KCS Completion Code
+  and returns the corresponding additional status of transport interface.
+
+  @param [in]  CompletionCode     The Completion Code returned from KCS.
+  @param [out] CompletionCodeStr  Human readable string of IPMI Completion Code.
+  @param [out] AdditionalStatus   Return the addtional status.
+
+  @retval  EFI_SUCCESS            The information of Completion Code is returned.
+  @retval  EFI_NOT_FOUND          No information of Completion Code is returned.
+  @retval  EFI_INVALID_PARAMETER  The given parameter is incorrect.
+
+**/
+EFI_STATUS
+IpmiHelperCheckCompletionCode (
+  IN   UINT8                                      CompletionCode,
+  OUT  CHAR16                                     **CompletionCodeStr,
+  OUT  MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS  *AdditionalStatus
+  )
+{
+  UINT8                                        Index;
+  MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING  *ThisCcMapping;
+
+  if ((CompletionCodeStr == NULL) || (AdditionalStatus == NULL)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  *AdditionalStatus = 0;
+  ThisCcMapping     = IpmiCompletionCodeMapping;
+  for (Index = 0; Index < IpmiCompletionCodeMappingEntries; Index++) {
+    if (ThisCcMapping->CompletionCode == CompletionCode) {
+      *CompletionCodeStr = ThisCcMapping->CompletionCodeString;
+      *AdditionalStatus  = ThisCcMapping->AdditionalStatus;
+      return EFI_SUCCESS;
+    }
+
+    ThisCcMapping++;
+  }
+
+  return EFI_NOT_FOUND;
+}
-- 
2.37.1.windows.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [edk2-platforms][PATCH 2/2] ManageabilityPkg/ManageabilityTransportKcsLib: Add debug message of IPMI KCS Completion Code
  2023-05-09  7:56 [edk2-platforms][PATCH 1/2] ManageabilityPkg: Add Manageability IPMI helper Library Chang, Abner
@ 2023-05-09  7:56 ` Chang, Abner
  2023-05-09 23:54   ` Isaac Oram
  2023-05-09 10:25 ` [edk2-platforms][PATCH 1/2] ManageabilityPkg: Add Manageability IPMI helper Library Attar, AbdulLateef (Abdul Lateef)
  2023-05-09 23:50 ` Isaac Oram
  2 siblings, 1 reply; 7+ messages in thread
From: Chang, Abner @ 2023-05-09  7:56 UTC (permalink / raw)
  To: devel; +Cc: Isaac Oram, Abdul Lateef Attar, Nickle Wang, Tinh Nguyen

From: abnchang <abnchang@amd.com>

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

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: Tinh Nguyen <tinhnguyen@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/Common/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/Common/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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [edk2-platforms][PATCH 1/2] ManageabilityPkg: Add Manageability IPMI helper Library
  2023-05-09  7:56 [edk2-platforms][PATCH 1/2] ManageabilityPkg: Add Manageability IPMI helper Library Chang, Abner
  2023-05-09  7:56 ` [edk2-platforms][PATCH 2/2] ManageabilityPkg/ManageabilityTransportKcsLib: Add debug message of IPMI KCS Completion Code Chang, Abner
@ 2023-05-09 10:25 ` Attar, AbdulLateef (Abdul Lateef)
  2023-05-09 23:50 ` Isaac Oram
  2 siblings, 0 replies; 7+ messages in thread
From: Attar, AbdulLateef (Abdul Lateef) @ 2023-05-09 10:25 UTC (permalink / raw)
  To: Chang, Abner, devel@edk2.groups.io; +Cc: Isaac Oram, Nickle Wang, Tinh Nguyen

[AMD Official Use Only - General]

Reviewed-by: Abdul Lateef Attar <abdattar@amd.com>

-----Original Message-----
From: Chang, Abner <Abner.Chang@amd.com>
Sent: 09 May 2023 13:26
To: devel@edk2.groups.io
Cc: Isaac Oram <isaac.w.oram@intel.com>; Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Nickle Wang <nicklew@nvidia.com>; Tinh Nguyen <tinhnguyen@os.amperecomputing.com>
Subject: [edk2-platforms][PATCH 1/2] ManageabilityPkg: Add Manageability IPMI helper Library

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

Add IPMI helper library to print debug message of IPMI Completion Code in human readable string and return the transport interface additional status.

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: Tinh Nguyen <tinhnguyen@os.amperecomputing.com>
---
 .../BaseManageabilityTransportHelper.inf      |  1 +
 .../Library/ManageabilityTransportHelperLib.h | 24 +++++++
 .../Library/ManageabilityTransportIpmiLib.h   | 13 +++-
 .../Library/ManageabilityTransportLib.h       | 11 +--
 .../BaseManageabilityTransportIpmiHelper.c    | 70 +++++++++++++++++++
 5 files changed, 112 insertions(+), 7 deletions(-)  create mode 100644 Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportIpmiHelper.c

diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.inf b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.inf
index c9e5eaef60..0936449fda 100644
--- a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.inf
+++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelper
+++ Lib/BaseManageabilityTransportHelper.inf
@@ -21,6 +21,7 @@

 [Sources]
   BaseManageabilityTransportHelper.c
+  BaseManageabilityTransportIpmiHelper.c

 [LibraryClasses]
   BaseMemoryLib
diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelperLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelperLib.h
index c2c98d6c2d..11a1bd0521 100644
--- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelperLib.h
+++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHe
+++ lperLib.h
@@ -187,4 +187,28 @@ HelperManageabilityDebugPrint (
   ...
   );

+///
+/// IPMI Helper Functions.
+///
+
+/**
+  This function returns a human readable string of IPMI KCS Completion
+Code
+  and returns the corresponding additional status of transport interface.
+
+  @param [in]  CompletionCode     The Completion Code returned from KCS.
+  @param [out] CompletionCodeStr  Human readable string of IPMI Completion Code.
+  @param [out] AdditionalStatus   Return the addtional status.
+
+  @retval  EFI_SUCCESS            The information of Completion Code is returned.
+  @retval  EFI_NOT_FOUND          No information of Completion Code is returned.
+  @retval  EFI_INVALID_PARAMETER  The given parameter is incorrect.
+
+**/
+EFI_STATUS
+IpmiHelperCheckCompletionCode (
+  IN   UINT8                                      CompletionCode,
+  OUT  CHAR16                                     **CompletionCodeStr,
+  OUT  MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS  *AdditionalStatus
+  );
+
 #endif
diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIpmiLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIpmiLib.h
index 1628255a6a..6d136e460f 100644
--- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIpmiLib.h
+++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIp
+++ miLib.h
@@ -16,9 +16,18 @@
 /// the payload.
 ///
 typedef struct {
-  UINT8    Lun:2;
-  UINT8    NetFn:6;
+  UINT8    Lun   : 2;
+  UINT8    NetFn : 6;
   UINT8    Command;
 } MANAGEABILITY_IPMI_TRANSPORT_HEADER;

+///
+/// The IPMI Completion Code mapping.
+///
+typedef struct {
+  UINT8                                        CompletionCode;
+  CHAR16                                       *CompletionCodeString;
+  MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS    AdditionalStatus;
+} MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING;
+
 #endif
diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h
index 04072aee89..f423a1ed44 100644
--- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h
+++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLi
+++ b.h
@@ -61,11 +61,12 @@ typedef union {
 /// Additional transport interface status.
 ///
 typedef UINT32 MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS;
-#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERRORS      0x00000000
-#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_ERROR          0x00000001
-#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_READ   0x00000002
-#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_WRITE  0x00000004 -#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NOT_AVAILABLE  0xffffffff
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERRORS        0x00000000
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_ERROR            0x00000001
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_READ     0x00000002
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_WRITE    0x00000004
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_INVALID_COMMAND  0x00000008
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NOT_AVAILABLE    0xffffffff

 ///
 /// Additional transport interface features.
diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportIpmiHelper.c b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportIpmiHelper.c
new file mode 100644
index 0000000000..8710cafc99
--- /dev/null
+++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelper
+++ Lib/BaseManageabilityTransportIpmiHelper.c
@@ -0,0 +1,70 @@
+/** @file
+  Null instance of Manageability IPMI Helper Library
+
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights
+reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent **/
+
+#include <Uefi.h>
+#include <Library/DebugLib.h>
+#include <Library/ManageabilityTransportIpmiLib.h>
+
+#include <IndustryStandard/Ipmi.h>
+
+//
+// BaseManageabilityTransportHelper is used by PEI, DXE and SMM.
+// Make sure the global variables added here should be unchangeable.
+//
+MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING  IpmiCompletionCodeMapping[] = {
+  { IPMI_COMP_CODE_NORMAL,          L"IPMI Completion Code - Normal",          MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERRORS       },
+  { IPMI_COMP_CODE_NODE_BUSY,       L"IPMI Completion Code - Busy",            MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_READ    },
+  { IPMI_COMP_CODE_INVALID_COMMAND, L"IPMI Completion Code - Invalid
+command", MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_INVALID_COMMAND }
+};
+
+UINT8  IpmiCompletionCodeMappingEntries = sizeof
+(IpmiCompletionCodeMapping) / sizeof
+(MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING);
+
+///
+/// IPMI Helper Functions.
+///
+
+/**
+  This function returns a human readable string of IPMI KCS Completion
+Code
+  and returns the corresponding additional status of transport interface.
+
+  @param [in]  CompletionCode     The Completion Code returned from KCS.
+  @param [out] CompletionCodeStr  Human readable string of IPMI Completion Code.
+  @param [out] AdditionalStatus   Return the addtional status.
+
+  @retval  EFI_SUCCESS            The information of Completion Code is returned.
+  @retval  EFI_NOT_FOUND          No information of Completion Code is returned.
+  @retval  EFI_INVALID_PARAMETER  The given parameter is incorrect.
+
+**/
+EFI_STATUS
+IpmiHelperCheckCompletionCode (
+  IN   UINT8                                      CompletionCode,
+  OUT  CHAR16                                     **CompletionCodeStr,
+  OUT  MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS  *AdditionalStatus
+  )
+{
+  UINT8                                        Index;
+  MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING  *ThisCcMapping;
+
+  if ((CompletionCodeStr == NULL) || (AdditionalStatus == NULL)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  *AdditionalStatus = 0;
+  ThisCcMapping     = IpmiCompletionCodeMapping;
+  for (Index = 0; Index < IpmiCompletionCodeMappingEntries; Index++) {
+    if (ThisCcMapping->CompletionCode == CompletionCode) {
+      *CompletionCodeStr = ThisCcMapping->CompletionCodeString;
+      *AdditionalStatus  = ThisCcMapping->AdditionalStatus;
+      return EFI_SUCCESS;
+    }
+
+    ThisCcMapping++;
+  }
+
+  return EFI_NOT_FOUND;
+}
--
2.37.1.windows.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-platforms][PATCH 1/2] ManageabilityPkg: Add Manageability IPMI helper Library
  2023-05-09  7:56 [edk2-platforms][PATCH 1/2] ManageabilityPkg: Add Manageability IPMI helper Library Chang, Abner
  2023-05-09  7:56 ` [edk2-platforms][PATCH 2/2] ManageabilityPkg/ManageabilityTransportKcsLib: Add debug message of IPMI KCS Completion Code Chang, Abner
  2023-05-09 10:25 ` [edk2-platforms][PATCH 1/2] ManageabilityPkg: Add Manageability IPMI helper Library Attar, AbdulLateef (Abdul Lateef)
@ 2023-05-09 23:50 ` Isaac Oram
  2023-05-10  2:09   ` Chang, Abner
  2 siblings, 1 reply; 7+ messages in thread
From: Isaac Oram @ 2023-05-09 23:50 UTC (permalink / raw)
  To: abner.chang@amd.com, devel@edk2.groups.io
  Cc: Abdul Lateef Attar, Nickle Wang, Tinh Nguyen

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

I noted that the BaseManageabilityTransportIpmiHelper.c file header comment indicates that this is a NULL library implementation which seems incorrect/misleading.  I think that this can be fixed before pushing.

-----Original Message-----
From: abner.chang@amd.com <abner.chang@amd.com> 
Sent: Tuesday, May 9, 2023 12:56 AM
To: devel@edk2.groups.io
Cc: Oram, Isaac W <isaac.w.oram@intel.com>; Abdul Lateef Attar <abdattar@amd.com>; Nickle Wang <nicklew@nvidia.com>; Tinh Nguyen <tinhnguyen@os.amperecomputing.com>
Subject: [edk2-platforms][PATCH 1/2] ManageabilityPkg: Add Manageability IPMI helper Library

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

Add IPMI helper library to print debug message of IPMI Completion Code in human readable string and return the transport interface additional status.

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: Tinh Nguyen <tinhnguyen@os.amperecomputing.com>
---
 .../BaseManageabilityTransportHelper.inf      |  1 +
 .../Library/ManageabilityTransportHelperLib.h | 24 +++++++
 .../Library/ManageabilityTransportIpmiLib.h   | 13 +++-
 .../Library/ManageabilityTransportLib.h       | 11 +--
 .../BaseManageabilityTransportIpmiHelper.c    | 70 +++++++++++++++++++
 5 files changed, 112 insertions(+), 7 deletions(-)  create mode 100644 Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportIpmiHelper.c

diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.inf b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.inf
index c9e5eaef60..0936449fda 100644
--- a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.inf
+++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelper
+++ Lib/BaseManageabilityTransportHelper.inf
@@ -21,6 +21,7 @@
 
 [Sources]
   BaseManageabilityTransportHelper.c
+  BaseManageabilityTransportIpmiHelper.c
 
 [LibraryClasses]
   BaseMemoryLib
diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelperLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelperLib.h
index c2c98d6c2d..11a1bd0521 100644
--- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelperLib.h
+++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHe
+++ lperLib.h
@@ -187,4 +187,28 @@ HelperManageabilityDebugPrint (
   ...
   );
 
+///
+/// IPMI Helper Functions.
+///
+
+/**
+  This function returns a human readable string of IPMI KCS Completion 
+Code
+  and returns the corresponding additional status of transport interface.
+
+  @param [in]  CompletionCode     The Completion Code returned from KCS.
+  @param [out] CompletionCodeStr  Human readable string of IPMI Completion Code.
+  @param [out] AdditionalStatus   Return the addtional status.
+
+  @retval  EFI_SUCCESS            The information of Completion Code is returned.
+  @retval  EFI_NOT_FOUND          No information of Completion Code is returned.
+  @retval  EFI_INVALID_PARAMETER  The given parameter is incorrect.
+
+**/
+EFI_STATUS
+IpmiHelperCheckCompletionCode (
+  IN   UINT8                                      CompletionCode,
+  OUT  CHAR16                                     **CompletionCodeStr,
+  OUT  MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS  *AdditionalStatus
+  );
+
 #endif
diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIpmiLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIpmiLib.h
index 1628255a6a..6d136e460f 100644
--- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIpmiLib.h
+++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIp
+++ miLib.h
@@ -16,9 +16,18 @@
 /// the payload.
 ///
 typedef struct {
-  UINT8    Lun:2;
-  UINT8    NetFn:6;
+  UINT8    Lun   : 2;
+  UINT8    NetFn : 6;
   UINT8    Command;
 } MANAGEABILITY_IPMI_TRANSPORT_HEADER;
 
+///
+/// The IPMI Completion Code mapping.
+///
+typedef struct {
+  UINT8                                        CompletionCode;
+  CHAR16                                       *CompletionCodeString;
+  MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS    AdditionalStatus;
+} MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING;
+
 #endif
diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h
index 04072aee89..f423a1ed44 100644
--- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h
+++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLi
+++ b.h
@@ -61,11 +61,12 @@ typedef union {
 /// Additional transport interface status.
 ///
 typedef UINT32 MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS;
-#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERRORS      0x00000000
-#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_ERROR          0x00000001
-#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_READ   0x00000002
-#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_WRITE  0x00000004 -#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NOT_AVAILABLE  0xffffffff
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERRORS        0x00000000
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_ERROR            0x00000001
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_READ     0x00000002
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_WRITE    0x00000004
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_INVALID_COMMAND  0x00000008
+#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NOT_AVAILABLE    0xffffffff
 
 ///
 /// Additional transport interface features.
diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportIpmiHelper.c b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportIpmiHelper.c
new file mode 100644
index 0000000000..8710cafc99
--- /dev/null
+++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelper
+++ Lib/BaseManageabilityTransportIpmiHelper.c
@@ -0,0 +1,70 @@
+/** @file
+  Null instance of Manageability IPMI Helper Library
+
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights 
+reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent **/
+
+#include <Uefi.h>
+#include <Library/DebugLib.h>
+#include <Library/ManageabilityTransportIpmiLib.h>
+
+#include <IndustryStandard/Ipmi.h>
+
+//
+// BaseManageabilityTransportHelper is used by PEI, DXE and SMM.
+// Make sure the global variables added here should be unchangeable.
+//
+MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING  IpmiCompletionCodeMapping[] = {
+  { IPMI_COMP_CODE_NORMAL,          L"IPMI Completion Code - Normal",          MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERRORS       },
+  { IPMI_COMP_CODE_NODE_BUSY,       L"IPMI Completion Code - Busy",            MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_READ    },
+  { IPMI_COMP_CODE_INVALID_COMMAND, L"IPMI Completion Code - Invalid 
+command", MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_INVALID_COMMAND } 
+};
+
+UINT8  IpmiCompletionCodeMappingEntries = sizeof 
+(IpmiCompletionCodeMapping) / sizeof 
+(MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING);
+
+///
+/// IPMI Helper Functions.
+///
+
+/**
+  This function returns a human readable string of IPMI KCS Completion 
+Code
+  and returns the corresponding additional status of transport interface.
+
+  @param [in]  CompletionCode     The Completion Code returned from KCS.
+  @param [out] CompletionCodeStr  Human readable string of IPMI Completion Code.
+  @param [out] AdditionalStatus   Return the addtional status.
+
+  @retval  EFI_SUCCESS            The information of Completion Code is returned.
+  @retval  EFI_NOT_FOUND          No information of Completion Code is returned.
+  @retval  EFI_INVALID_PARAMETER  The given parameter is incorrect.
+
+**/
+EFI_STATUS
+IpmiHelperCheckCompletionCode (
+  IN   UINT8                                      CompletionCode,
+  OUT  CHAR16                                     **CompletionCodeStr,
+  OUT  MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS  *AdditionalStatus
+  )
+{
+  UINT8                                        Index;
+  MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING  *ThisCcMapping;
+
+  if ((CompletionCodeStr == NULL) || (AdditionalStatus == NULL)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  *AdditionalStatus = 0;
+  ThisCcMapping     = IpmiCompletionCodeMapping;
+  for (Index = 0; Index < IpmiCompletionCodeMappingEntries; Index++) {
+    if (ThisCcMapping->CompletionCode == CompletionCode) {
+      *CompletionCodeStr = ThisCcMapping->CompletionCodeString;
+      *AdditionalStatus  = ThisCcMapping->AdditionalStatus;
+      return EFI_SUCCESS;
+    }
+
+    ThisCcMapping++;
+  }
+
+  return EFI_NOT_FOUND;
+}
--
2.37.1.windows.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-platforms][PATCH 2/2] ManageabilityPkg/ManageabilityTransportKcsLib: Add debug message of IPMI KCS Completion Code
  2023-05-09  7:56 ` [edk2-platforms][PATCH 2/2] ManageabilityPkg/ManageabilityTransportKcsLib: Add debug message of IPMI KCS Completion Code Chang, Abner
@ 2023-05-09 23:54   ` Isaac Oram
  2023-05-10  2:31     ` Chang, Abner
  0 siblings, 1 reply; 7+ messages in thread
From: Isaac Oram @ 2023-05-09 23:54 UTC (permalink / raw)
  To: abner.chang@amd.com, devel@edk2.groups.io
  Cc: Abdul Lateef Attar, Nickle Wang, Tinh Nguyen

Reviewed-by: Isaac Oram <isaac.w.oram@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.chang@amd.com <abner.chang@amd.com> 
Sent: Tuesday, May 9, 2023 12:56 AM
To: devel@edk2.groups.io
Cc: Oram, Isaac W <isaac.w.oram@intel.com>; Abdul Lateef Attar <abdattar@amd.com>; Nickle Wang <nicklew@nvidia.com>; Tinh Nguyen <tinhnguyen@os.amperecomputing.com>
Subject: [edk2-platforms][PATCH 2/2] ManageabilityPkg/ManageabilityTransportKcsLib: Add debug message of IPMI KCS Completion Code

From: abnchang <abnchang@amd.com>

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

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: Tinh Nguyen <tinhnguyen@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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-platforms][PATCH 1/2] ManageabilityPkg: Add Manageability IPMI helper Library
  2023-05-09 23:50 ` Isaac Oram
@ 2023-05-10  2:09   ` Chang, Abner
  0 siblings, 0 replies; 7+ messages in thread
From: Chang, Abner @ 2023-05-10  2:09 UTC (permalink / raw)
  To: Oram, Isaac W, devel@edk2.groups.io
  Cc: Attar, AbdulLateef (Abdul Lateef), Nickle Wang, Tinh Nguyen

[AMD Official Use Only - General]

Sure, I will.

Thanks for catching this.
Abner

> -----Original Message-----
> From: Oram, Isaac W <isaac.w.oram@intel.com>
> Sent: Wednesday, May 10, 2023 7:51 AM
> To: Chang, Abner <Abner.Chang@amd.com>; devel@edk2.groups.io
> Cc: Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Nickle
> Wang <nicklew@nvidia.com>; Tinh Nguyen
> <tinhnguyen@os.amperecomputing.com>
> Subject: RE: [edk2-platforms][PATCH 1/2] ManageabilityPkg: Add
> Manageability IPMI helper Library
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> Reviewed-by: Isaac Oram <isaac.w.oram@intel.com>
> 
> I noted that the BaseManageabilityTransportIpmiHelper.c file header
> comment indicates that this is a NULL library implementation which seems
> incorrect/misleading.  I think that this can be fixed before pushing.
> 
> -----Original Message-----
> From: abner.chang@amd.com <abner.chang@amd.com>
> Sent: Tuesday, May 9, 2023 12:56 AM
> To: devel@edk2.groups.io
> Cc: Oram, Isaac W <isaac.w.oram@intel.com>; Abdul Lateef Attar
> <abdattar@amd.com>; Nickle Wang <nicklew@nvidia.com>; Tinh Nguyen
> <tinhnguyen@os.amperecomputing.com>
> Subject: [edk2-platforms][PATCH 1/2] ManageabilityPkg: Add Manageability
> IPMI helper Library
> 
> From: Abner Chang <abner.chang@amd.com>
> 
> Add IPMI helper library to print debug message of IPMI Completion Code in
> human readable string and return the transport interface additional status.
> 
> 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: Tinh Nguyen <tinhnguyen@os.amperecomputing.com>
> ---
>  .../BaseManageabilityTransportHelper.inf      |  1 +
>  .../Library/ManageabilityTransportHelperLib.h | 24 +++++++
>  .../Library/ManageabilityTransportIpmiLib.h   | 13 +++-
>  .../Library/ManageabilityTransportLib.h       | 11 +--
>  .../BaseManageabilityTransportIpmiHelper.c    | 70 +++++++++++++++++++
>  5 files changed, 112 insertions(+), 7 deletions(-)  create mode 100644
> Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/B
> aseManageabilityTransportIpmiHelper.c
> 
> diff --git
> a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib
> /BaseManageabilityTransportHelper.inf
> b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib
> /BaseManageabilityTransportHelper.inf
> index c9e5eaef60..0936449fda 100644
> ---
> a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib
> /BaseManageabilityTransportHelper.inf
> +++
> b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelper
> +++ Lib/BaseManageabilityTransportHelper.inf
> @@ -21,6 +21,7 @@
> 
>  [Sources]
>    BaseManageabilityTransportHelper.c
> +  BaseManageabilityTransportIpmiHelper.c
> 
>  [LibraryClasses]
>    BaseMemoryLib
> diff --git
> a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelpe
> rLib.h
> b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelpe
> rLib.h
> index c2c98d6c2d..11a1bd0521 100644
> ---
> a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelpe
> rLib.h
> +++
> b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHe
> +++ lperLib.h
> @@ -187,4 +187,28 @@ HelperManageabilityDebugPrint (
>    ...
>    );
> 
> +///
> +/// IPMI Helper Functions.
> +///
> +
> +/**
> +  This function returns a human readable string of IPMI KCS Completion
> +Code
> +  and returns the corresponding additional status of transport interface.
> +
> +  @param [in]  CompletionCode     The Completion Code returned from KCS.
> +  @param [out] CompletionCodeStr  Human readable string of IPMI
> Completion Code.
> +  @param [out] AdditionalStatus   Return the addtional status.
> +
> +  @retval  EFI_SUCCESS            The information of Completion Code is
> returned.
> +  @retval  EFI_NOT_FOUND          No information of Completion Code is
> returned.
> +  @retval  EFI_INVALID_PARAMETER  The given parameter is incorrect.
> +
> +**/
> +EFI_STATUS
> +IpmiHelperCheckCompletionCode (
> +  IN   UINT8                                      CompletionCode,
> +  OUT  CHAR16                                     **CompletionCodeStr,
> +  OUT  MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS
> *AdditionalStatus
> +  );
> +
>  #endif
> diff --git
> a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIpmiLi
> b.h
> b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIpmiLi
> b.h
> index 1628255a6a..6d136e460f 100644
> ---
> a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIpmiLi
> b.h
> +++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIp
> +++ miLib.h
> @@ -16,9 +16,18 @@
>  /// the payload.
>  ///
>  typedef struct {
> -  UINT8    Lun:2;
> -  UINT8    NetFn:6;
> +  UINT8    Lun   : 2;
> +  UINT8    NetFn : 6;
>    UINT8    Command;
>  } MANAGEABILITY_IPMI_TRANSPORT_HEADER;
> 
> +///
> +/// The IPMI Completion Code mapping.
> +///
> +typedef struct {
> +  UINT8                                        CompletionCode;
> +  CHAR16                                       *CompletionCodeString;
> +  MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS    AdditionalStatus;
> +} MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING;
> +
>  #endif
> diff --git
> a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h
> b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h
> index 04072aee89..f423a1ed44 100644
> ---
> a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h
> +++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLi
> +++ b.h
> @@ -61,11 +61,12 @@ typedef union {
>  /// Additional transport interface status.
>  ///
>  typedef UINT32 MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS;
> -#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERRORS
> 0x00000000
> -#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_ERROR
> 0x00000001
> -#define
> MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_READ
> 0x00000002
> -#define
> MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_WRITE
> 0x00000004 -#define
> MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NOT_AVAILABLE
> 0xffffffff
> +#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERRORS
> 0x00000000
> +#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_ERROR
> 0x00000001
> +#define
> MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_READ
> 0x00000002
> +#define
> MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_WRITE
> 0x00000004
> +#define
> MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_INVALID_COMMAND
> 0x00000008
> +#define
> MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NOT_AVAILABLE
> 0xffffffff
> 
>  ///
>  /// Additional transport interface features.
> diff --git
> a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib
> /BaseManageabilityTransportIpmiHelper.c
> b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib
> /BaseManageabilityTransportIpmiHelper.c
> new file mode 100644
> index 0000000000..8710cafc99
> --- /dev/null
> +++
> b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelper
> +++ Lib/BaseManageabilityTransportIpmiHelper.c
> @@ -0,0 +1,70 @@
> +/** @file
> +  Null instance of Manageability IPMI Helper Library
> +
> +  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights
> +reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent **/
> +
> +#include <Uefi.h>
> +#include <Library/DebugLib.h>
> +#include <Library/ManageabilityTransportIpmiLib.h>
> +
> +#include <IndustryStandard/Ipmi.h>
> +
> +//
> +// BaseManageabilityTransportHelper is used by PEI, DXE and SMM.
> +// Make sure the global variables added here should be unchangeable.
> +//
> +MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING
> IpmiCompletionCodeMapping[] = {
> +  { IPMI_COMP_CODE_NORMAL,          L"IPMI Completion Code - Normal",
> MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERRORS       },
> +  { IPMI_COMP_CODE_NODE_BUSY,       L"IPMI Completion Code - Busy",
> MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_READ    },
> +  { IPMI_COMP_CODE_INVALID_COMMAND, L"IPMI Completion Code -
> Invalid
> +command",
> MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_INVALID_COMMAND }
> +};
> +
> +UINT8  IpmiCompletionCodeMappingEntries = sizeof
> +(IpmiCompletionCodeMapping) / sizeof
> +(MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING);
> +
> +///
> +/// IPMI Helper Functions.
> +///
> +
> +/**
> +  This function returns a human readable string of IPMI KCS Completion
> +Code
> +  and returns the corresponding additional status of transport interface.
> +
> +  @param [in]  CompletionCode     The Completion Code returned from KCS.
> +  @param [out] CompletionCodeStr  Human readable string of IPMI
> Completion Code.
> +  @param [out] AdditionalStatus   Return the addtional status.
> +
> +  @retval  EFI_SUCCESS            The information of Completion Code is
> returned.
> +  @retval  EFI_NOT_FOUND          No information of Completion Code is
> returned.
> +  @retval  EFI_INVALID_PARAMETER  The given parameter is incorrect.
> +
> +**/
> +EFI_STATUS
> +IpmiHelperCheckCompletionCode (
> +  IN   UINT8                                      CompletionCode,
> +  OUT  CHAR16                                     **CompletionCodeStr,
> +  OUT  MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS
> *AdditionalStatus
> +  )
> +{
> +  UINT8                                        Index;
> +  MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING  *ThisCcMapping;
> +
> +  if ((CompletionCodeStr == NULL) || (AdditionalStatus == NULL)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  *AdditionalStatus = 0;
> +  ThisCcMapping     = IpmiCompletionCodeMapping;
> +  for (Index = 0; Index < IpmiCompletionCodeMappingEntries; Index++) {
> +    if (ThisCcMapping->CompletionCode == CompletionCode) {
> +      *CompletionCodeStr = ThisCcMapping->CompletionCodeString;
> +      *AdditionalStatus  = ThisCcMapping->AdditionalStatus;
> +      return EFI_SUCCESS;
> +    }
> +
> +    ThisCcMapping++;
> +  }
> +
> +  return EFI_NOT_FOUND;
> +}
> --
> 2.37.1.windows.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-platforms][PATCH 2/2] ManageabilityPkg/ManageabilityTransportKcsLib: Add debug message of IPMI KCS Completion Code
  2023-05-09 23:54   ` Isaac Oram
@ 2023-05-10  2:31     ` Chang, Abner
  0 siblings, 0 replies; 7+ messages in thread
From: Chang, Abner @ 2023-05-10  2:31 UTC (permalink / raw)
  To: Oram, Isaac W, devel@edk2.groups.io
  Cc: Attar, AbdulLateef (Abdul Lateef), Nickle Wang, Tinh Nguyen

[AMD Official Use Only - General]

Hi Isaac,
I fixed those typos and had a push.

Thanks 
Abner

> -----Original Message-----
> From: Oram, Isaac W <isaac.w.oram@intel.com>
> Sent: Wednesday, May 10, 2023 7:54 AM
> To: Chang, Abner <Abner.Chang@amd.com>; devel@edk2.groups.io
> Cc: Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Nickle
> Wang <nicklew@nvidia.com>; Tinh Nguyen
> <tinhnguyen@os.amperecomputing.com>
> Subject: RE: [edk2-platforms][PATCH 2/2]
> ManageabilityPkg/ManageabilityTransportKcsLib: Add debug message of
> IPMI KCS Completion Code
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> Reviewed-by: Isaac Oram <isaac.w.oram@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.chang@amd.com <abner.chang@amd.com>
> Sent: Tuesday, May 9, 2023 12:56 AM
> To: devel@edk2.groups.io
> Cc: Oram, Isaac W <isaac.w.oram@intel.com>; Abdul Lateef Attar
> <abdattar@amd.com>; Nickle Wang <nicklew@nvidia.com>; Tinh Nguyen
> <tinhnguyen@os.amperecomputing.com>
> Subject: [edk2-platforms][PATCH 2/2]
> ManageabilityPkg/ManageabilityTransportKcsLib: Add debug message of
> IPMI KCS Completion Code
> 
> From: abnchang <abnchang@amd.com>
> 
> Print out IPMI Completion Code and return additional transport interface
> status.
> 
> 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: Tinh Nguyen <tinhnguyen@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/Commo
> n/ManageabilityTransportKcs.h
> b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Comm
> on/ManageabilityTransportKcs.h
> index 8c6a64416a..166aa8dcde 100644
> ---
> a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Commo
> n/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/Commo
> n/KcsCommon.c
> b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Comm
> on/KcsCommon.c
> index a8c6a674c9..84792311be 100644
> ---
> a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Commo
> n/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/M
> anageabilityTransportKcs.c
> b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/M
> anageabilityTransportKcs.c
> index 9175556a26..c2d1ac6b62 100644
> ---
> a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/M
> anageabilityTransportKcs.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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-05-10  2:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-09  7:56 [edk2-platforms][PATCH 1/2] ManageabilityPkg: Add Manageability IPMI helper Library Chang, Abner
2023-05-09  7:56 ` [edk2-platforms][PATCH 2/2] ManageabilityPkg/ManageabilityTransportKcsLib: Add debug message of IPMI KCS Completion Code Chang, Abner
2023-05-09 23:54   ` Isaac Oram
2023-05-10  2:31     ` Chang, Abner
2023-05-09 10:25 ` [edk2-platforms][PATCH 1/2] ManageabilityPkg: Add Manageability IPMI helper Library Attar, AbdulLateef (Abdul Lateef)
2023-05-09 23:50 ` Isaac Oram
2023-05-10  2:09   ` Chang, Abner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox