Re: [edk2-devel] [edk2-platforms][PATCH V5-1] IpmiFeaturePkg:Provided multiple IPMI interface support in PEI

2023-08-02 Thread Isaac Oram
Pushed as 421e64019d4622b049f510ba8eef7c82fba7b32d

Note I fixed PatchCheck.py issues and committed in an order that doesn't break 
git bisect.


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




Re: [edk2-devel][edk2-platforms][PATCH V5-1] IpmiFeaturePkg:Provided multiple IPMI interface support in PEI

2023-08-02 Thread Isaac Oram
Reviewed-by: Isaac Oram 

-Original Message-
From: Arun K  
Sent: Tuesday, July 25, 2023 8:36 AM
To: devel@edk2.groups.io; Arun K 
Cc: Oram, Isaac W ; Desimone, Nathaniel L 
; Ramkumar Krishnamoorthi ; 
Gao, Liming 
Subject: [edk2-devel][edk2-platforms][PATCH V5-1] IpmiFeaturePkg:Provided 
multiple IPMI interface support in PEI

Created IpmiTransport2 PPI/Protocol to support multiple
IPMI BMC Interface support such as KCS/BT/SSIF/IPMB with 2 API's
IpmiSubmitCommand2 & IpmiSubmitCommand2Ex.
IpmiSubmitCommand2 - This API use the default interface
(PcdDefaultSystemInterface) to send IPMI command.
IpmiSubmitCommand2Ex - This API use the specific interface type
to send IPMI command which is passed as an argument.

Cc: Isaac Oram 
Cc: Nate DeSimone 
Cc: Liming Gao 

Signed-off-by: Arun K 
---
 .../GenericIpmi/Pei/PeiGenericIpmi.c  | 550 +-
 .../GenericIpmi/Pei/PeiGenericIpmi.h  |  75 ++-
 .../GenericIpmi/Pei/PeiGenericIpmi.inf|  17 +
 .../GenericIpmi/Pei/PeiIpmiBmc.c  | 117 ++--
 .../GenericIpmi/Pei/PeiIpmiBmc.h  |  11 +-
 .../GenericIpmi/Pei/PeiIpmiBmcDef.h   |  86 +--
 .../GenericIpmi/Pei/PeiIpmiHooks.c| 346 +++
 .../GenericIpmi/Pei/PeiIpmiHooks.h| 218 +++
 8 files changed, 1159 insertions(+), 261 deletions(-)
 create mode 100644 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiHooks.c
 create mode 100644 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiHooks.h

diff --git 
a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
index e8b99b6900..61e7ce4ecd 100644
--- 
a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
+++ 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
@@ -3,6 +3,7 @@


   @copyright

   Copyright 2017 - 2021 Intel Corporation. 

+  Copyright (c) 1985 - 2023, American Megatrends International LLC. 

   SPDX-License-Identifier: BSD-2-Clause-Patent

 **/



@@ -10,10 +11,208 @@
 #include "PeiGenericIpmi.h"

 #include 

 #include 

+#include 



 ///

-// Function Implementations

-//

+

+static EFI_PEI_NOTIFY_DESCRIPTOR  mNotifyList = {

+  EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | 
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,

+  ,

+  UpdateIpmiInstancePtr

+};

+

+/**

+Initialize the API and parameters for IPMI Transport2 Instance

+

+@param[in] IpmiInstance Pointer to IPMI Instance

+

+@return VOID

+

+**/

+VOID

+InitIpmiTransport2 (

+  IN  PEI_IPMI_BMC_INSTANCE_DATA  *IpmiInstance

+  )

+{

+  IpmiInstance->IpmiTransport2Ppi.InterfaceType   = FixedPcdGet8 
(PcdDefaultSystemInterface);

+  IpmiInstance->IpmiTransport2Ppi.IpmiTransport2BmcStatus = BmcStatusOk;

+  IpmiInstance->IpmiTransport2Ppi.IpmiSubmitCommand2  = 
PeiIpmiSendCommand2;

+  IpmiInstance->IpmiTransport2Ppi.IpmiSubmitCommand2Ex= 
PeiIpmiSendCommand2Ex;

+

+  if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {

+if (!EFI_ERROR (PlatformIpmiIoRangeSet (FixedPcdGet16 
(PcdBtControlPort {

+  InitBtInterfaceData (>IpmiTransport2Ppi);

+}

+  }

+

+  if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {

+InitSsifInterfaceData (>IpmiTransport2Ppi);

+  }

+

+  if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {

+InitIpmbInterfaceData (>IpmiTransport2Ppi);

+  }

+}

+

+/*++

+

+Routine Description:

+  Notify callback function for interfaces.

+

+Arguments:

+  PeiServices  - Describes the list of possible PEI Services.

+  NotifyDescriptor - Pointer to notify descriptor.

+  Ppi  - Pointer to Ppi.

+

+Returns:

+  Status

+

+--*/

+EFI_STATUS

+EFIAPI

+NotifyCallback (

+  IN EFI_PEI_SERVICES   **PeiServices,

+  IN EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyDescriptor,

+  IN VOID   *Ppi

+  )

+{

+  EFI_STATUS  Status;

+  PEI_IPMI_BMC_INSTANCE_DATA  *IpmiInstance;

+  PEI_IPMI_DATA_HOB   *IpmiInstancePtrHob;

+  EFI_HOB_GUID_TYPE   *GuidHob;

+  IPMI_INTERFACE_STATEInterfaceState;

+

+  InterfaceState = IpmiInterfaceNotReady;

+

+  GuidHob = GetFirstGuidHob ();

+  ASSERT (GuidHob != NULL);

+  if (GuidHob == NULL) {

+return EFI_NOT_FOUND;

+  }

+

+  IpmiInstancePtrHob = (PEI_IPMI_DATA_HOB *)GET_GUID_HOB_DATA (GuidHob);

+  IpmiInstance   = (PEI_IPMI_BMC_INSTANCE_DATA 
*)IpmiInstancePtrHob->IpmiInstance;

+

+  if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {

+InitSsifInterfaceData (>IpmiTransport2Ppi);

+

+if (IpmiInstance->IpmiTransport2Ppi.Interface.Ssif.InterfaceState == 
IpmiInterfaceInitialized) {

+  InterfaceState = IpmiInterfaceInitialized;

+}

+  }

+

+  if 

[edk2-devel][edk2-platforms][PATCH V5-1] IpmiFeaturePkg:Provided multiple IPMI interface support in PEI

2023-07-25 Thread Arun K via groups.io
Created IpmiTransport2 PPI/Protocol to support multiple
IPMI BMC Interface support such as KCS/BT/SSIF/IPMB with 2 API's
IpmiSubmitCommand2 & IpmiSubmitCommand2Ex.
IpmiSubmitCommand2 - This API use the default interface
(PcdDefaultSystemInterface) to send IPMI command.
IpmiSubmitCommand2Ex - This API use the specific interface type
to send IPMI command which is passed as an argument.

Cc: Isaac Oram 
Cc: Nate DeSimone 
Cc: Liming Gao 

Signed-off-by: Arun K 
---
 .../GenericIpmi/Pei/PeiGenericIpmi.c  | 550 +-
 .../GenericIpmi/Pei/PeiGenericIpmi.h  |  75 ++-
 .../GenericIpmi/Pei/PeiGenericIpmi.inf|  17 +
 .../GenericIpmi/Pei/PeiIpmiBmc.c  | 117 ++--
 .../GenericIpmi/Pei/PeiIpmiBmc.h  |  11 +-
 .../GenericIpmi/Pei/PeiIpmiBmcDef.h   |  86 +--
 .../GenericIpmi/Pei/PeiIpmiHooks.c| 346 +++
 .../GenericIpmi/Pei/PeiIpmiHooks.h| 218 +++
 8 files changed, 1159 insertions(+), 261 deletions(-)
 create mode 100644 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiHooks.c
 create mode 100644 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiHooks.h

diff --git 
a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
index e8b99b6900..61e7ce4ecd 100644
--- 
a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
+++ 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
@@ -3,6 +3,7 @@


   @copyright

   Copyright 2017 - 2021 Intel Corporation. 

+  Copyright (c) 1985 - 2023, American Megatrends International LLC. 

   SPDX-License-Identifier: BSD-2-Clause-Patent

 **/



@@ -10,10 +11,208 @@
 #include "PeiGenericIpmi.h"

 #include 

 #include 

+#include 



 ///

-// Function Implementations

-//

+

+static EFI_PEI_NOTIFY_DESCRIPTOR  mNotifyList = {

+  EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | 
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,

+  ,

+  UpdateIpmiInstancePtr

+};

+

+/**

+Initialize the API and parameters for IPMI Transport2 Instance

+

+@param[in] IpmiInstance Pointer to IPMI Instance

+

+@return VOID

+

+**/

+VOID

+InitIpmiTransport2 (

+  IN  PEI_IPMI_BMC_INSTANCE_DATA  *IpmiInstance

+  )

+{

+  IpmiInstance->IpmiTransport2Ppi.InterfaceType   = FixedPcdGet8 
(PcdDefaultSystemInterface);

+  IpmiInstance->IpmiTransport2Ppi.IpmiTransport2BmcStatus = BmcStatusOk;

+  IpmiInstance->IpmiTransport2Ppi.IpmiSubmitCommand2  = 
PeiIpmiSendCommand2;

+  IpmiInstance->IpmiTransport2Ppi.IpmiSubmitCommand2Ex= 
PeiIpmiSendCommand2Ex;

+

+  if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {

+if (!EFI_ERROR (PlatformIpmiIoRangeSet (FixedPcdGet16 
(PcdBtControlPort {

+  InitBtInterfaceData (>IpmiTransport2Ppi);

+}

+  }

+

+  if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {

+InitSsifInterfaceData (>IpmiTransport2Ppi);

+  }

+

+  if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {

+InitIpmbInterfaceData (>IpmiTransport2Ppi);

+  }

+}

+

+/*++

+

+Routine Description:

+  Notify callback function for interfaces.

+

+Arguments:

+  PeiServices  - Describes the list of possible PEI Services.

+  NotifyDescriptor - Pointer to notify descriptor.

+  Ppi  - Pointer to Ppi.

+

+Returns:

+  Status

+

+--*/

+EFI_STATUS

+EFIAPI

+NotifyCallback (

+  IN EFI_PEI_SERVICES   **PeiServices,

+  IN EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyDescriptor,

+  IN VOID   *Ppi

+  )

+{

+  EFI_STATUS  Status;

+  PEI_IPMI_BMC_INSTANCE_DATA  *IpmiInstance;

+  PEI_IPMI_DATA_HOB   *IpmiInstancePtrHob;

+  EFI_HOB_GUID_TYPE   *GuidHob;

+  IPMI_INTERFACE_STATEInterfaceState;

+

+  InterfaceState = IpmiInterfaceNotReady;

+

+  GuidHob = GetFirstGuidHob ();

+  ASSERT (GuidHob != NULL);

+  if (GuidHob == NULL) {

+return EFI_NOT_FOUND;

+  }

+

+  IpmiInstancePtrHob = (PEI_IPMI_DATA_HOB *)GET_GUID_HOB_DATA (GuidHob);

+  IpmiInstance   = (PEI_IPMI_BMC_INSTANCE_DATA 
*)IpmiInstancePtrHob->IpmiInstance;

+

+  if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {

+InitSsifInterfaceData (>IpmiTransport2Ppi);

+

+if (IpmiInstance->IpmiTransport2Ppi.Interface.Ssif.InterfaceState == 
IpmiInterfaceInitialized) {

+  InterfaceState = IpmiInterfaceInitialized;

+}

+  }

+

+  if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {

+InitIpmbInterfaceData (>IpmiTransport2Ppi);

+

+if (IpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.InterfaceState == 
IpmiInterfaceInitialized) {

+  InterfaceState = IpmiInterfaceInitialized;

+}

+  }

+

+  // Default Interface data should be initialized to install Ipmi Transport2 
Protocol.

+  if (InterfaceState !=