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

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