public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiSolStatus: IPMI Serail over Lan Driver
@ 2023-05-12  7:29 Chang, Abner
  2023-05-12  7:29 ` [edk2-platforms][PATCH 2/2] ManageabilityPkg/IpmiSolStatus: Add to ManageabilityPkg Chang, Abner
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Chang, Abner @ 2023-05-12  7:29 UTC (permalink / raw)
  To: devel; +Cc: Isaac Oram, Abdul Lateef Attar, Nickle Wang, Tinh Nguyen

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

IpmiSolStatus is cloned from
edk2-platforms/Features/Intel/OutOfBandManagement/
IpmiFeaturePkg/SolStatus in order to consolidate
edk2 system manageability support in one place.
Uncustify is applied to C files and no functionalities
are changed in this patch.

We will still keep the one under IpmiFeaturePkg/SolStatus
until the reference to this instance are removed from
platforms.

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>
---
 .../ManageabilityPkg/ManageabilityPkg.dec     |   4 +
 .../Universal/IpmiSolStatus/SolStatus.inf     |  37 ++++
 .../Universal/IpmiSolStatus/SolStatus.c       | 164 ++++++++++++++++++
 3 files changed, 205 insertions(+)
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.c

diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec b/Features/ManageabilityPkg/ManageabilityPkg.dec
index 38813c5f48..c11bf5d0df 100644
--- a/Features/ManageabilityPkg/ManageabilityPkg.dec
+++ b/Features/ManageabilityPkg/ManageabilityPkg.dec
@@ -72,6 +72,10 @@
   # @Prompt MCTP KCS (Memory mapped) I/O base address
   gManageabilityPkgTokenSpaceGuid.PcdMctpKcsBaseAddress|0xca2|UINT32|0x00000004
 
+  ## This is the value of SOL channels supported on platform.
+  # @Prompt SOL channel number
+  gManageabilityPkgTokenSpaceGuid.PcdMaxSolChannels|3|UINT8|0x00000100
+
 [PcdsFeatureFlag]
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiEnable|FALSE|BOOLEAN|0x10000001
   gManageabilityPkgTokenSpaceGuid.PcdManageabilitySmmIpmiEnable|FALSE|BOOLEAN|0x10000002
diff --git a/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf b/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
new file mode 100644
index 0000000000..1d7cbf1a08
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
@@ -0,0 +1,37 @@
+### @file
+# Component description file for IPMI Serial Over LAN (SOL) driver.
+#
+# Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+###
+
+[Defines]
+  INF_VERSION              = 0x00010005
+  BASE_NAME                = SolStatus
+  FILE_GUID                = 1AF7E6C4-7678-4A6D-9240-E8BA17C3B772
+  MODULE_TYPE              = DXE_DRIVER
+  PI_SPECIFICATION_VERSION = 0x0001000A
+  VERSION_STRING           = 1.0
+  ENTRY_POINT              = SolStatusEntryPoint
+
+[Sources]
+  SolStatus.c
+
+[Packages]
+  ManageabilityPkg/ManageabilityPkg.dec
+  MdePkg/MdePkg.dec
+
+[Pcd]
+  gManageabilityPkgTokenSpaceGuid.PcdMaxSolChannels
+
+[LibraryClasses]
+  DebugLib
+  IpmiCommandLib
+  PcdLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+
+[Depex]
+  TRUE
diff --git a/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.c b/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.c
new file mode 100644
index 0000000000..996386372e
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.c
@@ -0,0 +1,164 @@
+/** @file
+  IPMI Serial Over Lan Driver.
+
+Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/IpmiCommandLib.h>
+#include <IndustryStandard/Ipmi.h>
+
+#define SOL_CMD_RETRY_COUNT  10
+
+/*++
+
+Routine Description:
+
+    This routine gets the SOL payload status or settings for a specific channel.
+
+Arguments:
+    Channel         - LAN channel naumber.
+    ParamSel        - Configuration parameter selection.
+    Data            - Information returned from BMC.
+Returns:
+    EFI_SUCCESS     - SOL configuration parameters are successfully read from BMC.
+    Others          - SOL configuration parameters could not be read from BMC.
+
+--*/
+EFI_STATUS
+GetSolStatus (
+  IN UINT8      Channel,
+  IN UINT8      ParamSel,
+  IN OUT UINT8  *Data
+  )
+{
+  EFI_STATUS                                      Status = EFI_SUCCESS;
+  IPMI_GET_SOL_CONFIGURATION_PARAMETERS_REQUEST   GetConfigurationParametersRequest;
+  IPMI_GET_SOL_CONFIGURATION_PARAMETERS_RESPONSE  GetConfigurationParametersResponse;
+  UINT32                                          DataSize;
+  UINT8                                           RetryCount;
+
+  for (RetryCount = 0; RetryCount < SOL_CMD_RETRY_COUNT; RetryCount++) {
+    ZeroMem (&GetConfigurationParametersRequest, sizeof (GetConfigurationParametersRequest));
+    GetConfigurationParametersRequest.ChannelNumber.Bits.ChannelNumber = Channel;
+    GetConfigurationParametersRequest.ParameterSelector                = ParamSel;
+
+    ZeroMem (&GetConfigurationParametersResponse, sizeof (GetConfigurationParametersResponse));
+
+    DataSize = sizeof (GetConfigurationParametersResponse);
+    Status   = IpmiGetSolConfigurationParameters (
+                 &GetConfigurationParametersRequest,
+                 &GetConfigurationParametersResponse,
+                 &DataSize
+                 );
+
+    if (Status == EFI_SUCCESS) {
+      break;
+    } else {
+      gBS->Stall (100000);
+    }
+  }
+
+  if (Status == EFI_SUCCESS) {
+    *Data = GetConfigurationParametersResponse.ParameterData[0];
+  }
+
+  return Status;
+}
+
+/*++
+
+Routine Description:
+
+    This routine sets the SOL payload configuration parameters for a specific channel.
+
+Arguments:
+    Channel         - LAN channel naumber.
+    ParamSel        - Configuration parameter selection.
+    Data            - Configuration parameter values.
+Returns:
+    EFI_SUCCESS     - SOL configuration parameters are sent to BMC.
+    Others          - SOL configuration parameters could not be sent to BMC.
+
+--*/
+EFI_STATUS
+SetSolParams (
+  IN UINT8  Channel,
+  IN UINT8  ParamSel,
+  IN UINT8  Data
+  )
+{
+  EFI_STATUS                                     Status = EFI_SUCCESS;
+  IPMI_SET_SOL_CONFIGURATION_PARAMETERS_REQUEST  SetConfigurationParametersRequest;
+  UINT8                                          CompletionCode;
+  UINT8                                          RetryCount;
+
+  for (RetryCount = 0; RetryCount < SOL_CMD_RETRY_COUNT; RetryCount++) {
+    ZeroMem (&SetConfigurationParametersRequest, sizeof (SetConfigurationParametersRequest));
+    SetConfigurationParametersRequest.ChannelNumber.Bits.ChannelNumber = Channel;
+    SetConfigurationParametersRequest.ParameterSelector                = ParamSel;
+    SetConfigurationParametersRequest.ParameterData[0]                 = Data;
+
+    CompletionCode = 0;
+
+    Status = IpmiSetSolConfigurationParameters (
+               &SetConfigurationParametersRequest,
+               sizeof (SetConfigurationParametersRequest),
+               &CompletionCode
+               );
+
+    if (Status == EFI_SUCCESS) {
+      break;
+    } else {
+      gBS->Stall (100000);
+    }
+  }
+
+  return Status;
+}
+
+/*++
+
+  Routine Description:
+    This is the standard EFI driver point. This function initializes
+    the private data required for creating SOL Status Driver.
+
+  Arguments:
+    ImageHandle     - Handle for the image of this driver
+    SystemTable     - Pointer to the EFI System Table
+
+  Returns:
+    EFI_SUCCESS     - Protocol successfully installed
+    EFI_UNSUPPORTED - Protocol can't be installed.
+
+--*/
+EFI_STATUS
+EFIAPI
+SolStatusEntryPoint (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS  Status = EFI_SUCCESS;
+  UINT8       Channel;
+  BOOLEAN     SolEnabled = FALSE;
+
+  for (Channel = 1; Channel <= PcdGet8 (PcdMaxSolChannels); Channel++) {
+    Status = GetSolStatus (Channel, IPMI_SOL_CONFIGURATION_PARAMETER_SOL_ENABLE, &SolEnabled);
+    if (Status == EFI_SUCCESS) {
+      DEBUG ((DEBUG_ERROR, "SOL enabling status for channel %x is %x\n", Channel, SolEnabled));
+    } else {
+      DEBUG ((DEBUG_ERROR, "Failed to get channel %x SOL status from BMC!, status is %x\n", Channel, Status));
+    }
+  }
+
+  return Status;
+}
-- 
2.37.1.windows.1


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

* [edk2-platforms][PATCH 2/2] ManageabilityPkg/IpmiSolStatus: Add to ManageabilityPkg
  2023-05-12  7:29 [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiSolStatus: IPMI Serail over Lan Driver Chang, Abner
@ 2023-05-12  7:29 ` Chang, Abner
  2023-05-19  3:16   ` [edk2-devel] " Isaac Oram
       [not found] ` <175E54D0598FD173.30531@groups.io>
  2023-05-19  3:16 ` [edk2-devel] [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiSolStatus: IPMI Serail over Lan Driver Isaac Oram
  2 siblings, 1 reply; 5+ messages in thread
From: Chang, Abner @ 2023-05-12  7:29 UTC (permalink / raw)
  To: devel; +Cc: Isaac Oram, Abdul Lateef Attar, Nickle Wang

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

Add IpmiSolStatus to ManageabilityPkg.

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>
---
 Features/ManageabilityPkg/ManageabilityPkg.dec      | 1 +
 Features/ManageabilityPkg/Include/Manageability.dsc | 4 ++++
 Features/ManageabilityPkg/ManageabilityPkg.dsc      | 2 ++
 Features/ManageabilityPkg/Include/PostMemory.fdf    | 4 ++++
 4 files changed, 11 insertions(+)

diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec b/Features/ManageabilityPkg/ManageabilityPkg.dec
index c11bf5d0df..6bf65feda4 100644
--- a/Features/ManageabilityPkg/ManageabilityPkg.dec
+++ b/Features/ManageabilityPkg/ManageabilityPkg.dec
@@ -83,4 +83,5 @@
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmEnable|FALSE|BOOLEAN|0x10000004
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable|FALSE|BOOLEAN|0x10000005
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmSmbiosTransferEnable|FALSE|BOOLEAN|0x10000006
+  gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiSolStatus|FALSE|BOOLEAN|0x10000009
 
diff --git a/Features/ManageabilityPkg/Include/Manageability.dsc b/Features/ManageabilityPkg/Include/Manageability.dsc
index a432b0ff26..5f014b5d8d 100644
--- a/Features/ManageabilityPkg/Include/Manageability.dsc
+++ b/Features/ManageabilityPkg/Include/Manageability.dsc
@@ -51,3 +51,7 @@
 !if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable == TRUE
   ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.inf
 !endif
+
+!if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiSolStatus == TRUE
+  ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
+!endif
diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dsc b/Features/ManageabilityPkg/ManageabilityPkg.dsc
index e3baf27f2a..6426f84f1f 100644
--- a/Features/ManageabilityPkg/ManageabilityPkg.dsc
+++ b/Features/ManageabilityPkg/ManageabilityPkg.dsc
@@ -37,6 +37,7 @@
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmEnable              |TRUE
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable              |TRUE
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmSmbiosTransferEnable|TRUE
+  gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiSolStatus           |TRUE
 
 #
 # Include common libraries
@@ -53,5 +54,6 @@
 
 [LibraryClasses]
   ManageabilityTransportLib|ManageabilityPkg/Library/BaseManageabilityTransportNullLib/BaseManageabilityTransportNull.inf
+  IpmiLib|MdeModulePkg/Library/BaseIpmiLibNull/BaseIpmiLibNull.inf
 
 !include Include/Manageability.dsc
diff --git a/Features/ManageabilityPkg/Include/PostMemory.fdf b/Features/ManageabilityPkg/Include/PostMemory.fdf
index 9100cb2646..2d04e736c1 100644
--- a/Features/ManageabilityPkg/Include/PostMemory.fdf
+++ b/Features/ManageabilityPkg/Include/PostMemory.fdf
@@ -26,3 +26,7 @@
 !if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable == TRUE
   INF ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.inf
 !endif
+
+!if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiSolStatus == TRUE
+  INF ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
+!endif
-- 
2.37.1.windows.1


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

* Re: [edk2-devel] [edk2-platforms][PATCH 2/2] ManageabilityPkg/IpmiSolStatus: Add to ManageabilityPkg
       [not found] ` <175E54D0598FD173.30531@groups.io>
@ 2023-05-18  2:50   ` Nickle Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Nickle Wang @ 2023-05-18  2:50 UTC (permalink / raw)
  To: devel@edk2.groups.io, Chang, Abner
  Cc: Isaac Oram, Attar, AbdulLateef (Abdul Lateef)



Reviewed-by: Nickle Wang <nicklew@nvidia.com>

Regards,
Nickle

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang, Abner
> via groups.io
> Sent: Friday, May 12, 2023 3:29 PM
> 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>
> Subject: [edk2-devel] [edk2-platforms][PATCH 2/2]
> ManageabilityPkg/IpmiSolStatus: Add to ManageabilityPkg
> 
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
> 
> 
> From: Abner Chang <abner.chang@amd.com>
> 
> Add IpmiSolStatus to ManageabilityPkg.
> 
> 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>
> ---
>  Features/ManageabilityPkg/ManageabilityPkg.dec      | 1 +
>  Features/ManageabilityPkg/Include/Manageability.dsc | 4 ++++
>  Features/ManageabilityPkg/ManageabilityPkg.dsc      | 2 ++
>  Features/ManageabilityPkg/Include/PostMemory.fdf    | 4 ++++
>  4 files changed, 11 insertions(+)
> 
> diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec
> b/Features/ManageabilityPkg/ManageabilityPkg.dec
> index c11bf5d0df..6bf65feda4 100644
> --- a/Features/ManageabilityPkg/ManageabilityPkg.dec
> +++ b/Features/ManageabilityPkg/ManageabilityPkg.dec
> @@ -83,4 +83,5 @@
> 
> gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmEnable|FALSE|BO
> OLEAN|0x10000004
> 
> gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable|FALSE|BO
> OLEAN|0x10000005
> 
> gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmSmbiosTransferEna
> ble|FALSE|BOOLEAN|0x10000006
> +
> gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiSolStatus|FALSE|B
> OOLEAN|0x10000009
> 
> diff --git a/Features/ManageabilityPkg/Include/Manageability.dsc
> b/Features/ManageabilityPkg/Include/Manageability.dsc
> index a432b0ff26..5f014b5d8d 100644
> --- a/Features/ManageabilityPkg/Include/Manageability.dsc
> +++ b/Features/ManageabilityPkg/Include/Manageability.dsc
> @@ -51,3 +51,7 @@
>  !if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable ==
> TRUE
>    ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.inf
>  !endif
> +
> +!if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiSolStatus ==
> TRUE
> +  ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
> +!endif
> diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dsc
> b/Features/ManageabilityPkg/ManageabilityPkg.dsc
> index e3baf27f2a..6426f84f1f 100644
> --- a/Features/ManageabilityPkg/ManageabilityPkg.dsc
> +++ b/Features/ManageabilityPkg/ManageabilityPkg.dsc
> @@ -37,6 +37,7 @@
>    gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmEnable
> |TRUE
>    gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable
> |TRUE
> 
> gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmSmbiosTransferEna
> ble|TRUE
> +  gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiSolStatus
> |TRUE
> 
>  #
>  # Include common libraries
> @@ -53,5 +54,6 @@
> 
>  [LibraryClasses]
> 
> ManageabilityTransportLib|ManageabilityPkg/Library/BaseManageabilityTransp
> ortNullLib/BaseManageabilityTransportNull.inf
> +  IpmiLib|MdeModulePkg/Library/BaseIpmiLibNull/BaseIpmiLibNull.inf
> 
>  !include Include/Manageability.dsc
> diff --git a/Features/ManageabilityPkg/Include/PostMemory.fdf
> b/Features/ManageabilityPkg/Include/PostMemory.fdf
> index 9100cb2646..2d04e736c1 100644
> --- a/Features/ManageabilityPkg/Include/PostMemory.fdf
> +++ b/Features/ManageabilityPkg/Include/PostMemory.fdf
> @@ -26,3 +26,7 @@
>  !if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable ==
> TRUE
>    INF ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.inf
>  !endif
> +
> +!if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiSolStatus ==
> TRUE
> +  INF ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
> +!endif
> --
> 2.37.1.windows.1
> 
> 
> 
> 
> 


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

* Re: [edk2-devel] [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiSolStatus: IPMI Serail over Lan Driver
  2023-05-12  7:29 [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiSolStatus: IPMI Serail over Lan Driver Chang, Abner
  2023-05-12  7:29 ` [edk2-platforms][PATCH 2/2] ManageabilityPkg/IpmiSolStatus: Add to ManageabilityPkg Chang, Abner
       [not found] ` <175E54D0598FD173.30531@groups.io>
@ 2023-05-19  3:16 ` Isaac Oram
  2 siblings, 0 replies; 5+ messages in thread
From: Isaac Oram @ 2023-05-19  3:16 UTC (permalink / raw)
  To: devel@edk2.groups.io, abner.chang@amd.com
  Cc: Abdul Lateef Attar, Nickle Wang, Tinh Nguyen

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

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang, Abner via groups.io
Sent: Friday, May 12, 2023 12:29 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-devel] [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiSolStatus: IPMI Serail over Lan Driver

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

IpmiSolStatus is cloned from
edk2-platforms/Features/Intel/OutOfBandManagement/
IpmiFeaturePkg/SolStatus in order to consolidate
edk2 system manageability support in one place.
Uncustify is applied to C files and no functionalities are changed in this patch.

We will still keep the one under IpmiFeaturePkg/SolStatus until the reference to this instance are removed from platforms.

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>
---
 .../ManageabilityPkg/ManageabilityPkg.dec     |   4 +
 .../Universal/IpmiSolStatus/SolStatus.inf     |  37 ++++
 .../Universal/IpmiSolStatus/SolStatus.c       | 164 ++++++++++++++++++
 3 files changed, 205 insertions(+)
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.c

diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec b/Features/ManageabilityPkg/ManageabilityPkg.dec
index 38813c5f48..c11bf5d0df 100644
--- a/Features/ManageabilityPkg/ManageabilityPkg.dec
+++ b/Features/ManageabilityPkg/ManageabilityPkg.dec
@@ -72,6 +72,10 @@
   # @Prompt MCTP KCS (Memory mapped) I/O base address
   gManageabilityPkgTokenSpaceGuid.PcdMctpKcsBaseAddress|0xca2|UINT32|0x00000004
 
+  ## This is the value of SOL channels supported on platform.
+  # @Prompt SOL channel number
+  gManageabilityPkgTokenSpaceGuid.PcdMaxSolChannels|3|UINT8|0x00000100
+
 [PcdsFeatureFlag]
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiEnable|FALSE|BOOLEAN|0x10000001
   gManageabilityPkgTokenSpaceGuid.PcdManageabilitySmmIpmiEnable|FALSE|BOOLEAN|0x10000002
diff --git a/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf b/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
new file mode 100644
index 0000000000..1d7cbf1a08
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
@@ -0,0 +1,37 @@
+### @file
+# Component description file for IPMI Serial Over LAN (SOL) driver.
+#
+# Copyright (c) 2018 - 2019, Intel Corporation. All rights 
+reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # ###
+
+[Defines]
+  INF_VERSION              = 0x00010005
+  BASE_NAME                = SolStatus
+  FILE_GUID                = 1AF7E6C4-7678-4A6D-9240-E8BA17C3B772
+  MODULE_TYPE              = DXE_DRIVER
+  PI_SPECIFICATION_VERSION = 0x0001000A
+  VERSION_STRING           = 1.0
+  ENTRY_POINT              = SolStatusEntryPoint
+
+[Sources]
+  SolStatus.c
+
+[Packages]
+  ManageabilityPkg/ManageabilityPkg.dec
+  MdePkg/MdePkg.dec
+
+[Pcd]
+  gManageabilityPkgTokenSpaceGuid.PcdMaxSolChannels
+
+[LibraryClasses]
+  DebugLib
+  IpmiCommandLib
+  PcdLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+
+[Depex]
+  TRUE
diff --git a/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.c b/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.c
new file mode 100644
index 0000000000..996386372e
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.c
@@ -0,0 +1,164 @@
+/** @file
+  IPMI Serial Over Lan Driver.
+
+Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h> #include 
+<Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/IpmiCommandLib.h>
+#include <IndustryStandard/Ipmi.h>
+
+#define SOL_CMD_RETRY_COUNT  10
+
+/*++
+
+Routine Description:
+
+    This routine gets the SOL payload status or settings for a specific channel.
+
+Arguments:
+    Channel         - LAN channel naumber.
+    ParamSel        - Configuration parameter selection.
+    Data            - Information returned from BMC.
+Returns:
+    EFI_SUCCESS     - SOL configuration parameters are successfully read from BMC.
+    Others          - SOL configuration parameters could not be read from BMC.
+
+--*/
+EFI_STATUS
+GetSolStatus (
+  IN UINT8      Channel,
+  IN UINT8      ParamSel,
+  IN OUT UINT8  *Data
+  )
+{
+  EFI_STATUS                                      Status = EFI_SUCCESS;
+  IPMI_GET_SOL_CONFIGURATION_PARAMETERS_REQUEST   GetConfigurationParametersRequest;
+  IPMI_GET_SOL_CONFIGURATION_PARAMETERS_RESPONSE  GetConfigurationParametersResponse;
+  UINT32                                          DataSize;
+  UINT8                                           RetryCount;
+
+  for (RetryCount = 0; RetryCount < SOL_CMD_RETRY_COUNT; RetryCount++) {
+    ZeroMem (&GetConfigurationParametersRequest, sizeof (GetConfigurationParametersRequest));
+    GetConfigurationParametersRequest.ChannelNumber.Bits.ChannelNumber = Channel;
+    GetConfigurationParametersRequest.ParameterSelector                = ParamSel;
+
+    ZeroMem (&GetConfigurationParametersResponse, sizeof 
+ (GetConfigurationParametersResponse));
+
+    DataSize = sizeof (GetConfigurationParametersResponse);
+    Status   = IpmiGetSolConfigurationParameters (
+                 &GetConfigurationParametersRequest,
+                 &GetConfigurationParametersResponse,
+                 &DataSize
+                 );
+
+    if (Status == EFI_SUCCESS) {
+      break;
+    } else {
+      gBS->Stall (100000);
+    }
+  }
+
+  if (Status == EFI_SUCCESS) {
+    *Data = GetConfigurationParametersResponse.ParameterData[0];
+  }
+
+  return Status;
+}
+
+/*++
+
+Routine Description:
+
+    This routine sets the SOL payload configuration parameters for a specific channel.
+
+Arguments:
+    Channel         - LAN channel naumber.
+    ParamSel        - Configuration parameter selection.
+    Data            - Configuration parameter values.
+Returns:
+    EFI_SUCCESS     - SOL configuration parameters are sent to BMC.
+    Others          - SOL configuration parameters could not be sent to BMC.
+
+--*/
+EFI_STATUS
+SetSolParams (
+  IN UINT8  Channel,
+  IN UINT8  ParamSel,
+  IN UINT8  Data
+  )
+{
+  EFI_STATUS                                     Status = EFI_SUCCESS;
+  IPMI_SET_SOL_CONFIGURATION_PARAMETERS_REQUEST  SetConfigurationParametersRequest;
+  UINT8                                          CompletionCode;
+  UINT8                                          RetryCount;
+
+  for (RetryCount = 0; RetryCount < SOL_CMD_RETRY_COUNT; RetryCount++) {
+    ZeroMem (&SetConfigurationParametersRequest, sizeof (SetConfigurationParametersRequest));
+    SetConfigurationParametersRequest.ChannelNumber.Bits.ChannelNumber = Channel;
+    SetConfigurationParametersRequest.ParameterSelector                = ParamSel;
+    SetConfigurationParametersRequest.ParameterData[0]                 = Data;
+
+    CompletionCode = 0;
+
+    Status = IpmiSetSolConfigurationParameters (
+               &SetConfigurationParametersRequest,
+               sizeof (SetConfigurationParametersRequest),
+               &CompletionCode
+               );
+
+    if (Status == EFI_SUCCESS) {
+      break;
+    } else {
+      gBS->Stall (100000);
+    }
+  }
+
+  return Status;
+}
+
+/*++
+
+  Routine Description:
+    This is the standard EFI driver point. This function initializes
+    the private data required for creating SOL Status Driver.
+
+  Arguments:
+    ImageHandle     - Handle for the image of this driver
+    SystemTable     - Pointer to the EFI System Table
+
+  Returns:
+    EFI_SUCCESS     - Protocol successfully installed
+    EFI_UNSUPPORTED - Protocol can't be installed.
+
+--*/
+EFI_STATUS
+EFIAPI
+SolStatusEntryPoint (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS  Status = EFI_SUCCESS;
+  UINT8       Channel;
+  BOOLEAN     SolEnabled = FALSE;
+
+  for (Channel = 1; Channel <= PcdGet8 (PcdMaxSolChannels); Channel++) {
+    Status = GetSolStatus (Channel, IPMI_SOL_CONFIGURATION_PARAMETER_SOL_ENABLE, &SolEnabled);
+    if (Status == EFI_SUCCESS) {
+      DEBUG ((DEBUG_ERROR, "SOL enabling status for channel %x is %x\n", Channel, SolEnabled));
+    } else {
+      DEBUG ((DEBUG_ERROR, "Failed to get channel %x SOL status from BMC!, status is %x\n", Channel, Status));
+    }
+  }
+
+  return Status;
+}
--
2.37.1.windows.1







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

* Re: [edk2-devel] [edk2-platforms][PATCH 2/2] ManageabilityPkg/IpmiSolStatus: Add to ManageabilityPkg
  2023-05-12  7:29 ` [edk2-platforms][PATCH 2/2] ManageabilityPkg/IpmiSolStatus: Add to ManageabilityPkg Chang, Abner
@ 2023-05-19  3:16   ` Isaac Oram
  0 siblings, 0 replies; 5+ messages in thread
From: Isaac Oram @ 2023-05-19  3:16 UTC (permalink / raw)
  To: devel@edk2.groups.io, abner.chang@amd.com; +Cc: Abdul Lateef Attar, Nickle Wang

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

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang, Abner via groups.io
Sent: Friday, May 12, 2023 12:29 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>
Subject: [edk2-devel] [edk2-platforms][PATCH 2/2] ManageabilityPkg/IpmiSolStatus: Add to ManageabilityPkg

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

Add IpmiSolStatus to ManageabilityPkg.

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>
---
 Features/ManageabilityPkg/ManageabilityPkg.dec      | 1 +
 Features/ManageabilityPkg/Include/Manageability.dsc | 4 ++++
 Features/ManageabilityPkg/ManageabilityPkg.dsc      | 2 ++
 Features/ManageabilityPkg/Include/PostMemory.fdf    | 4 ++++
 4 files changed, 11 insertions(+)

diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec b/Features/ManageabilityPkg/ManageabilityPkg.dec
index c11bf5d0df..6bf65feda4 100644
--- a/Features/ManageabilityPkg/ManageabilityPkg.dec
+++ b/Features/ManageabilityPkg/ManageabilityPkg.dec
@@ -83,4 +83,5 @@
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmEnable|FALSE|BOOLEAN|0x10000004
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable|FALSE|BOOLEAN|0x10000005
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmSmbiosTransferEnable|FALSE|BOOLEAN|0x10000006
+  gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiSolStatus|FALSE|BOOLEAN|0x10000009
 
diff --git a/Features/ManageabilityPkg/Include/Manageability.dsc b/Features/ManageabilityPkg/Include/Manageability.dsc
index a432b0ff26..5f014b5d8d 100644
--- a/Features/ManageabilityPkg/Include/Manageability.dsc
+++ b/Features/ManageabilityPkg/Include/Manageability.dsc
@@ -51,3 +51,7 @@
 !if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable == TRUE
   ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.inf
 !endif
+
+!if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiSolStatus == TRUE
+  ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
+!endif
diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dsc b/Features/ManageabilityPkg/ManageabilityPkg.dsc
index e3baf27f2a..6426f84f1f 100644
--- a/Features/ManageabilityPkg/ManageabilityPkg.dsc
+++ b/Features/ManageabilityPkg/ManageabilityPkg.dsc
@@ -37,6 +37,7 @@
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmEnable              |TRUE
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable              |TRUE
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmSmbiosTransferEnable|TRUE
+  gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiSolStatus           |TRUE
 
 #
 # Include common libraries
@@ -53,5 +54,6 @@
 
 [LibraryClasses]
   ManageabilityTransportLib|ManageabilityPkg/Library/BaseManageabilityTransportNullLib/BaseManageabilityTransportNull.inf
+  IpmiLib|MdeModulePkg/Library/BaseIpmiLibNull/BaseIpmiLibNull.inf
 
 !include Include/Manageability.dsc
diff --git a/Features/ManageabilityPkg/Include/PostMemory.fdf b/Features/ManageabilityPkg/Include/PostMemory.fdf
index 9100cb2646..2d04e736c1 100644
--- a/Features/ManageabilityPkg/Include/PostMemory.fdf
+++ b/Features/ManageabilityPkg/Include/PostMemory.fdf
@@ -26,3 +26,7 @@
 !if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable == TRUE
   INF ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.inf
 !endif
+
+!if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiSolStatus == TRUE
+  INF ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
+!endif
-- 
2.37.1.windows.1







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

end of thread, other threads:[~2023-05-19  3:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-12  7:29 [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiSolStatus: IPMI Serail over Lan Driver Chang, Abner
2023-05-12  7:29 ` [edk2-platforms][PATCH 2/2] ManageabilityPkg/IpmiSolStatus: Add to ManageabilityPkg Chang, Abner
2023-05-19  3:16   ` [edk2-devel] " Isaac Oram
     [not found] ` <175E54D0598FD173.30531@groups.io>
2023-05-18  2:50   ` Nickle Wang
2023-05-19  3:16 ` [edk2-devel] [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiSolStatus: IPMI Serail over Lan Driver Isaac Oram

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