]> git.proxmox.com Git - mirror_edk2.git/commitdiff
RedfishPkg/RedfishHostInterface: Platform Redfish HI notification
authorAbner Chang <abner.chang@amd.com>
Mon, 19 Dec 2022 13:18:00 +0000 (21:18 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 20 Dec 2022 06:54:06 +0000 (06:54 +0000)
For some use cases, Redfish host interface table relies on
the certain EFI protocols installation at the driver connection.
Redfish host interface DXE driver is not able to build the
SMBIOS type 42h record at driver entry point. This patch adds
the mechanism in Redfish host interface DXE driver to listen
to EFI protocol installed by platform library that indicates
the necessary information is ready for building SMBIOS 42h
record.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Nickle Wang <nicklew@nvidia.com>
RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c

index 8d8389b9647bd74deff59d97e62c9ac108beaf44..22a8f9283cb48f01eb7ccfc9981e1a2325466524 100644 (file)
@@ -2,6 +2,7 @@
   Definitinos of RedfishHostInterfaceDxe driver.\r
 \r
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>\r
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.<BR>\r
 \r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -19,7 +20,7 @@
 /**\r
   Get platform Redfish host interface device descriptor.\r
 \r
-  @param[in] DeviceType         Pointer to retrieve device type.\r
+  @param[out] DeviceType        Pointer to retrieve device type.\r
   @param[out] DeviceDescriptor  Pointer to retrieve REDFISH_INTERFACE_DATA, caller has to free\r
                                 this memory using FreePool().\r
   @retval EFI_SUCCESS     Device descriptor is returned successfully in DeviceDescriptor.\r
@@ -28,7 +29,7 @@
 **/\r
 EFI_STATUS\r
 RedfishPlatformHostInterfaceDeviceDescriptor (\r
-  IN UINT8                    *DeviceType,\r
+  OUT UINT8                   *DeviceType,\r
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor\r
   );\r
 \r
@@ -40,7 +41,7 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
   @param[in, out] ProtocolRecord  Pointer to retrieve the first or the next protocol record.\r
                                   caller has to free the new protocol record returned from\r
                                   this function using FreePool().\r
-  param[in] IndexOfProtocolData   The index of protocol data.\r
+  @param[in] IndexOfProtocolData  The index of protocol data.\r
 \r
   @retval EFI_SUCCESS     Protocol records are all returned.\r
   @retval EFI_NOT_FOUND   No more protocol records.\r
@@ -52,4 +53,25 @@ RedfishPlatformHostInterfaceProtocolData (
   IN UINT8                                  IndexOfProtocolData\r
   );\r
 \r
+/**\r
+  Get the EFI protocol GUID installed by platform library which\r
+  indicates the necessary information is ready for building\r
+  SMBIOS 42h record.\r
+\r
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol\r
+                                        GUID.\r
+\r
+  @retval EFI_SUCCESS          Notification is required for building up\r
+                               SMBIOS type 42h record.\r
+  @retval EFI_UNSUPPORTED      Notification is not required for building up\r
+                               SMBIOS type 42h record.\r
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.\r
+  @retval Others               Other errors.\r
+**/\r
+\r
+EFI_STATUS\r
+RedfishPlatformHostInterfaceNotification (\r
+  OUT EFI_GUID  **InformationReadinessGuid\r
+  );\r
+\r
 #endif\r
index b30f9e37a4d2a108dffe6a461d903b7368cfe9e5..40642469c9a53f0c612f484c59043288e3a3b5cd 100644 (file)
@@ -2,6 +2,7 @@
   NULL instace of RedfishPlatformHostInterfaceLib\r
 \r
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>\r
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.<BR>\r
 \r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -23,7 +24,7 @@
 **/\r
 EFI_STATUS\r
 RedfishPlatformHostInterfaceDeviceDescriptor (\r
-  IN UINT8                    *DeviceType,\r
+  OUT UINT8                   *DeviceType,\r
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor\r
   )\r
 {\r
@@ -51,3 +52,26 @@ RedfishPlatformHostInterfaceProtocolData (
 {\r
   return EFI_NOT_FOUND;\r
 }\r
+\r
+/**\r
+  Get the EFI protocol GUID installed by platform library which\r
+  indicates the necessary information is ready for building\r
+  SMBIOS 42h record.\r
+\r
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol\r
+                                        GUID.\r
+\r
+  @retval EFI_SUCCESS          Notification is required for building up\r
+                               SMBIOS type 42h record.\r
+  @retval EFI_UNSUPPORTED      Notification is not required for building up\r
+                               SMBIOS type 42h record.\r
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.\r
+  @retval Others               Other errors.\r
+**/\r
+EFI_STATUS\r
+RedfishPlatformHostInterfaceNotification (\r
+  OUT EFI_GUID  **InformationReadinessGuid\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
index 623350bc261c3e445bff28de9a26ba3999d2d78f..3e12e0c8b9a54f1668144389df9d9bbaf10d4724 100644 (file)
@@ -6,6 +6,7 @@
 \r
   Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>\r
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.<BR>\r
 \r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -21,6 +22,9 @@
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 \r
+static EFI_EVENT  mPlatformHostInterfaceReadylEvent        = NULL;\r
+static VOID       *mPlatformHostInterfaceReadyRegistration = NULL;\r
+\r
 /**\r
   Create SMBIOS type 42 record for Redfish host interface.\r
 \r
@@ -238,6 +242,27 @@ ON_EXIT:
   return Status;\r
 }\r
 \r
+/**\r
+  Notification event of platform Redfish Host Interface readiness.\r
+\r
+  @param[in]  Event     Event whose notification function is being invoked.\r
+  @param[in]  Context   The pointer to the notification function's context,\r
+                        which is implementation-dependent.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformHostInterfaceInformationReady (\r
+  IN  EFI_EVENT  Event,\r
+  IN  VOID       *Context\r
+  )\r
+{\r
+  DEBUG ((DEBUG_INFO, "%a: Platform Redfish Host Interface informtion is ready\n", __FUNCTION__));\r
+\r
+  RedfishCreateSmbiosTable42 ();\r
+  return;\r
+}\r
+\r
 /**\r
   Main entry for this driver.\r
 \r
@@ -254,8 +279,52 @@ RedfishHostInterfaceDxeEntryPoint (
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
+  EFI_STATUS  Status;\r
+  EFI_GUID    *ReadyGuid;\r
+\r
+  DEBUG ((DEBUG_INFO, "%a: Entry\n.", __FUNCTION__));\r
+\r
   //\r
-  // Create SMBIOS type 42 record.\r
+  // Check if the Redfish Host Interface depends on\r
+  // the specific protocol installation.\r
   //\r
-  return RedfishCreateSmbiosTable42 ();\r
+  Status = RedfishPlatformHostInterfaceNotification (&ReadyGuid);\r
+  if (Status == EFI_SUCCESS) {\r
+    DEBUG ((DEBUG_INFO, "    Create protocol install notification to know the installation of platform Redfish host interface readiness\n"));\r
+    DEBUG ((DEBUG_INFO, "    Protocol GUID: %g\n", ReadyGuid));\r
+    //\r
+    // Register event for ReadyGuid protocol installed by\r
+    // platform Redfish host interface library.\r
+    //\r
+    Status = gBS->CreateEvent (\r
+                    EVT_NOTIFY_SIGNAL,\r
+                    TPL_CALLBACK,\r
+                    PlatformHostInterfaceInformationReady,\r
+                    NULL,\r
+                    &mPlatformHostInterfaceReadylEvent\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((DEBUG_ERROR, "    Fail to create event for the installation of platform Redfish host interface readiness.\n"));\r
+      return Status;\r
+    }\r
+\r
+    Status = gBS->RegisterProtocolNotify (\r
+                    ReadyGuid,\r
+                    mPlatformHostInterfaceReadylEvent,\r
+                    &mPlatformHostInterfaceReadyRegistration\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((DEBUG_ERROR, "    Fail to register event for the installation of platform Redfish host interface readiness.\n"));\r
+      return Status;\r
+    }\r
+\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if ((Status == EFI_UNSUPPORTED) || (Status == EFI_ALREADY_STARTED)) {\r
+    Status = RedfishCreateSmbiosTable42 ();\r
+  }\r
+\r
+  // Return other erros.\r
+  return Status;\r
 }\r