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: Liming Gao <gaoliming@byosoft.com.cn>,
	Isaac Oram <isaac.w.oram@intel.com>,
	Nate DeSimone <nathaniel.l.desimone@intel.com>,
	Abdul Lateef Attar <abdattar@amd.com>,
	Nickle Wang <nicklew@nvidia.com>,
	"Igor Kulchytskyy" <igork@ami.com>
Subject: [edk2-platforms][PATCH 5/7] ManageabilityPkg: Implement Ipmi Protocol/Ppi
Date: Wed, 8 Feb 2023 00:22:34 +0800	[thread overview]
Message-ID: <20230207162236.1406-6-abner.chang@amd.com> (raw)
In-Reply-To: <20230207162236.1406-1-abner.chang@amd.com>

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

Add Ipmi Protocol/Ppi implementation. The underlying
implementation is provided by IpmiBaseLib.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Abdul Lateef Attar <abdattar@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
---
 .../IpmiProtocol/Dxe/IpmiProtocolDxe.inf      |  37 +++++++
 .../Universal/IpmiProtocol/Pei/IpmiPpiPei.inf |  38 +++++++
 .../IpmiProtocol/Smm/IpmiProtocolSmm.inf      |  40 +++++++
 .../Universal/IpmiProtocol/Dxe/IpmiProtocol.c |  97 +++++++++++++++++
 .../Universal/IpmiProtocol/Pei/IpmiPpi.c      | 102 ++++++++++++++++++
 .../Universal/IpmiProtocol/Smm/IpmiProtocol.c |  98 +++++++++++++++++
 6 files changed, 412 insertions(+)
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocolDxe.inf
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiPei.inf
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocolSmm.inf
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.c
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.c

diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocolDxe.inf b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocolDxe.inf
new file mode 100644
index 0000000000..0737a5ad8f
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocolDxe.inf
@@ -0,0 +1,37 @@
+## @file
+# IPMI Protocol DXE Driver.
+#
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001d
+  BASE_NAME                      = IpmiDxe
+  FILE_GUID                      = BC41B0C2-9D8A-42B5-A28F-02CE0D4A6C28
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = IpmiEntry
+
+#
+#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64
+#
+
+[Sources]
+  IpmiProtocol.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  IpmiFeaturePkg/IpmiFeaturePkg.dec
+
+[LibraryClasses]
+  IpmiBaseLib
+  UefiDriverEntryPoint
+  UefiBootServicesTableLib
+
+[Protocols]
+  gIpmiProtocolGuid               # PROTOCOL ALWAYS_PRODUCED
+
+[Depex]
+  TRUE
diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiPei.inf b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiPei.inf
new file mode 100644
index 0000000000..7ba8584f84
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiPei.inf
@@ -0,0 +1,38 @@
+## @file
+# IPMI Protocol PEI Driver.
+#
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001d
+  BASE_NAME                      = IpmiPei
+  FILE_GUID                      = 7832F989-CB72-4715-ADCA-35C0B031856C
+  MODULE_TYPE                    = PEIM
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = IpmiEntry
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64
+#
+
+[Sources]
+  IpmiPpi.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  IpmiFeaturePkg/IpmiFeaturePkg.dec
+
+[LibraryClasses]
+  IpmiBaseLib
+  PeimEntryPoint
+
+[Ppis]
+  gPeiIpmiPpiGuid       # PPI ALWAYS PRODUCED
+
+[Depex]
+  TRUE
diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocolSmm.inf b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocolSmm.inf
new file mode 100644
index 0000000000..25a5771cb3
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocolSmm.inf
@@ -0,0 +1,40 @@
+## @file
+# IPMI Protocol SMM Driver.
+#
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64
+#
+[Defines]
+  INF_VERSION                         = 0x0001001d
+  BASE_NAME                           = IpmiSmm
+  FILE_GUID                           = CDD5D1DE-E3D3-4B1F-8689-DCC661561BB4
+  MODULE_TYPE                         = DXE_SMM_DRIVER
+  PI_SPECIFICATION_VERSION            = 0x0001000A
+  VERSION_STRING                      = 1.0
+  ENTRY_POINT                         = IpmiEntry
+
+[Sources]
+  IpmiProtocol.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  IpmiFeaturePkg/IpmiFeaturePkg.dec
+
+[LibraryClasses]
+  IpmiBaseLib
+  UefiDriverEntryPoint
+  UefiBootServicesTableLib
+  SmmServicesTableLib
+
+[Protocols]
+  gSmmIpmiProtocolGuid               # PROTOCOL ALWAYS_PRODUCED
+
+[Depex]
+  TRUE
diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.c
new file mode 100644
index 0000000000..1f0b88052e
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.c
@@ -0,0 +1,97 @@
+/** @file
+  This file provides IPMI Protocol implementation.
+
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <PiDxe.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/IpmiBaseLib.h>
+#include <Protocol/IpmiProtocol.h>
+
+/**
+  This service enables submitting commands via Ipmi.
+
+  @param[in]         This              This point for IPMI_PROTOCOL structure.
+  @param[in]         NetFunction       Net function of the command.
+  @param[in]         Command           IPMI Command.
+  @param[in]         RequestData       Command Request Data.
+  @param[in]         RequestDataSize   Size of Command Request Data.
+  @param[out]        ResponseData      Command Response Data. The completion code is the first byte of response data.
+  @param[in, out]    ResponseDataSize  Size of Command Response Data.
+
+  @retval EFI_SUCCESS            The command byte stream was successfully submit to the device and a response was successfully received.
+  @retval EFI_NOT_FOUND          The command was not successfully sent to the device or a response was not successfully received from the device.
+  @retval EFI_NOT_READY          Ipmi Device is not ready for Ipmi command access.
+  @retval EFI_DEVICE_ERROR       Ipmi Device hardware error.
+  @retval EFI_TIMEOUT            The command time out.
+  @retval EFI_UNSUPPORTED        The command was not successfully sent to the device.
+  @retval EFI_OUT_OF_RESOURCES   The resource allcation is out of resource or data size error.
+**/
+EFI_STATUS
+EFIAPI
+IpmiSubmitCommand (
+  IN     IPMI_PROTOCOL  *This,
+  IN     UINT8          NetFunction,
+  IN     UINT8          Command,
+  IN     UINT8          *RequestData,
+  IN     UINT32         RequestDataSize,
+  OUT    UINT8          *ResponseData,
+  IN OUT UINT32         *ResponseDataSize
+  )
+{
+  EFI_STATUS  Status;
+
+  Status = IpmiSendCommand (
+             NetFunction,
+             Command,
+             RequestData,
+             RequestDataSize,
+             ResponseData,
+             ResponseDataSize
+             );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: Failed to send IPMI command in DXE - %r\n", __FUNCTION__, Status));
+  }
+
+  return Status;
+}
+
+static IPMI_PROTOCOL  mIpmiProtocol = {
+  IpmiSubmitCommand
+};
+
+/**
+  The entry point of the Ipmi DXE driver.
+
+  @param[in] ImageHandle - Handle of this driver image
+  @param[in] SystemTable - Table containing standard EFI services
+
+  @retval EFI_SUCCESS    - IPMI Protocol is installed successfully.
+  @retval Otherwise      - Other errors.
+**/
+EFI_STATUS
+EFIAPI
+IpmiEntry (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  EFI_HANDLE  Handle;
+
+  Handle = NULL;
+  Status = gBS->InstallProtocolInterface (
+                  &Handle,
+                  &gIpmiProtocolGuid,
+                  EFI_NATIVE_INTERFACE,
+                  (VOID **)&mIpmiProtocol
+                  );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: Failed to install IPMI protocol - %r\n", __FUNCTION__, Status));
+  }
+
+  return Status;
+}
diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c
new file mode 100644
index 0000000000..913a9b0811
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c
@@ -0,0 +1,102 @@
+/** @file
+  This file provides IPMI PPI implementation.
+
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiPei.h>
+#include <Library/DebugLib.h>
+#include <Library/PeiServicesLib.h>
+#include <Library/IpmiBaseLib.h>
+#include <Ppi/IpmiPpi.h>
+
+/**
+  This service enables submitting commands via Ipmi.
+
+  @param[in]         This              This point for PEI_IPMI_PPI structure.
+  @param[in]         NetFunction       Net function of the command.
+  @param[in]         Command           IPMI Command.
+  @param[in]         RequestData       Command Request Data.
+  @param[in]         RequestDataSize   Size of Command Request Data.
+  @param[out]        ResponseData      Command Response Data. The completion code is the first byte of response data.
+  @param[in, out]    ResponseDataSize  Size of Command Response Data.
+
+  @retval EFI_SUCCESS            The command byte stream was successfully submit to the device and a response was successfully received.
+  @retval EFI_NOT_FOUND          The command was not successfully sent to the device or a response was not successfully received from the device.
+  @retval EFI_NOT_READY          Ipmi Device is not ready for Ipmi command access.
+  @retval EFI_DEVICE_ERROR       Ipmi Device hardware error.
+  @retval EFI_TIMEOUT            The command time out.
+  @retval EFI_UNSUPPORTED        The command was not successfully sent to the device.
+  @retval EFI_OUT_OF_RESOURCES   The resource allcation is out of resource or data size error.
+**/
+EFI_STATUS
+EFIAPI
+IpmiSubmitCommand (
+  IN     PEI_IPMI_PPI  *This,
+  IN     UINT8         NetFunction,
+  IN     UINT8         Command,
+  IN     UINT8         *RequestData,
+  IN     UINT32        RequestDataSize,
+  OUT    UINT8         *ResponseData,
+  IN OUT UINT32        *ResponseDataSize
+  )
+{
+  EFI_STATUS  Status;
+
+  Status = IpmiSendCommand (
+             NetFunction,
+             Command,
+             RequestData,
+             RequestDataSize,
+             ResponseData,
+             ResponseDataSize
+             );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: Failed to send IPMI command in PEI- %r\n", __FUNCTION__, Status));
+  }
+
+  return Status;
+}
+
+static PEI_IPMI_PPI  mPeiIpmiPpi = {
+  IpmiSubmitCommand
+};
+
+static EFI_PEI_PPI_DESCRIPTOR  mIpmiPpiList[] = {
+  {
+    (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+    &gPeiIpmiPpiGuid,
+    &mPeiIpmiPpi
+  }
+};
+
+/**
+  The entry point of the Ipmi PPI PEIM.
+
+  @param  FileHandle  Handle of the file being invoked.
+  @param  PeiServices Describes the list of possible PEI Services.
+
+  @retval EFI_SUCCESS   Indicates that Ipmi initialization completed successfully.
+  @retval Others        Indicates that Ipmi initialization could not complete successfully.
+**/
+EFI_STATUS
+EFIAPI
+IpmiEntry (
+  IN       EFI_PEI_FILE_HANDLE  FileHandle,
+  IN CONST EFI_PEI_SERVICES     **PeiServices
+  )
+{
+  EFI_STATUS  Status;
+
+  //
+  // Install IPMI PPI.
+  //
+  Status = PeiServicesInstallPpi (&mIpmiPpiList[0]);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: Failed to install IPMI PPI - %r\n", __FUNCTION__, Status));
+  }
+
+  return Status;
+}
diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.c
new file mode 100644
index 0000000000..ed14f9fbd1
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.c
@@ -0,0 +1,98 @@
+/** @file
+  This file provides IPMI SMM Protocol implementation.
+
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <PiDxe.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/SmmServicesTableLib.h>
+#include <Library/IpmiBaseLib.h>
+#include <Protocol/IpmiProtocol.h>
+
+/**
+  This service enables submitting commands via Ipmi.
+
+  @param[in]         This              This point for IPMI_PROTOCOL structure.
+  @param[in]         NetFunction       Net function of the command.
+  @param[in]         Command           IPMI Command.
+  @param[in]         RequestData       Command Request Data.
+  @param[in]         RequestDataSize   Size of Command Request Data.
+  @param[out]        ResponseData      Command Response Data. The completion code is the first byte of response data.
+  @param[in, out]    ResponseDataSize  Size of Command Response Data.
+
+  @retval EFI_SUCCESS            The command byte stream was successfully submit to the device and a response was successfully received.
+  @retval EFI_NOT_FOUND          The command was not successfully sent to the device or a response was not successfully received from the device.
+  @retval EFI_NOT_READY          Ipmi Device is not ready for Ipmi command access.
+  @retval EFI_DEVICE_ERROR       Ipmi Device hardware error.
+  @retval EFI_TIMEOUT            The command time out.
+  @retval EFI_UNSUPPORTED        The command was not successfully sent to the device.
+  @retval EFI_OUT_OF_RESOURCES   The resource allcation is out of resource or data size error.
+**/
+EFI_STATUS
+EFIAPI
+IpmiSubmitCommand (
+  IN     IPMI_PROTOCOL  *This,
+  IN     UINT8          NetFunction,
+  IN     UINT8          Command,
+  IN     UINT8          *RequestData,
+  IN     UINT32         RequestDataSize,
+  OUT    UINT8          *ResponseData,
+  IN OUT UINT32         *ResponseDataSize
+  )
+{
+  EFI_STATUS  Status;
+
+  Status = IpmiSendCommand (
+             NetFunction,
+             Command,
+             RequestData,
+             RequestDataSize,
+             ResponseData,
+             ResponseDataSize
+             );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: Failed to send IPMI command in DXE - %r\n", __FUNCTION__, Status));
+  }
+
+  return Status;
+}
+
+static IPMI_PROTOCOL  mIpmiProtocol = {
+  IpmiSubmitCommand
+};
+
+/**
+  The entry point of the Ipmi DXE driver.
+
+  @param[in] ImageHandle - Handle of this driver image
+  @param[in] SystemTable - Table containing standard EFI services
+
+  @retval EFI_SUCCESS    - IPMI Protocol is installed successfully.
+  @retval Otherwise      - Other errors.
+**/
+EFI_STATUS
+EFIAPI
+IpmiEntry (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  EFI_HANDLE  Handle;
+
+  Handle = NULL;
+  Status = gSmst->SmmInstallProtocolInterface (
+                    &Handle,
+                    &gSmmIpmiProtocolGuid,
+                    EFI_NATIVE_INTERFACE,
+                    (VOID **)&mIpmiProtocol
+                    );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: Failed to install IPMI SMM protocol - %r\n", __FUNCTION__, Status));
+  }
+
+  return Status;
+}
-- 
2.37.1.windows.1


  parent reply	other threads:[~2023-02-07 16:23 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07 16:22 [edk2-platforms][PATCH 0/7] Implementation of IPMI Protocol Chang, Abner
2023-02-07 16:22 ` [edk2-platforms][PATCH 1/7] IpmiFeaturePkg: Rename IpmiSubmitCommand function Chang, Abner
2023-02-16  1:43   ` Isaac Oram
2023-02-17  7:28     ` Chang, Abner
2023-02-07 16:22 ` [edk2-platforms][PATCH 2/7] ManageabilityPkg: Add diagrams Chang, Abner
2023-02-07 16:22 ` [edk2-platforms][PATCH 3/7] ManageabilityPkg: Add Readme file Chang, Abner
2023-02-16  1:44   ` Isaac Oram
2023-02-17  7:28     ` Chang, Abner
2023-02-07 16:22 ` [edk2-platforms][PATCH 4/7] ManageabilityPkg: Initial package Chang, Abner
2023-02-16  1:49   ` Isaac Oram
2023-02-17  7:29     ` Chang, Abner
2023-02-07 16:22 ` Chang, Abner [this message]
2023-02-16  1:47   ` [edk2-platforms][PATCH 5/7] ManageabilityPkg: Implement Ipmi Protocol/Ppi Isaac Oram
2023-02-17  7:29     ` Chang, Abner
2023-02-07 16:22 ` [edk2-platforms][PATCH 6/7] IpmiProtocol: Add to Manageability Package Chang, Abner
2023-02-07 16:22 ` [edk2-platforms][PATCH 7/7] edk2-platforms: Maintainers.txt Chang, Abner
2023-02-08  7:34   ` Michael D Kinney
     [not found] ` <174197631C900AFE.27199@groups.io>
2023-02-07 18:24   ` [edk2-devel] " Chang, Abner
2023-02-16  1:51     ` Isaac Oram
2023-02-17  7:30       ` Chang, Abner
2023-02-16  1:42 ` [edk2-platforms][PATCH 0/7] Implementation of IPMI Protocol Isaac Oram
2023-02-17  7:27   ` 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=20230207162236.1406-6-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