public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH V2 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification
@ 2022-12-19 14:51 Chang, Abner
  2022-12-19 15:11 ` Nickle Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Chang, Abner @ 2022-12-19 14:51 UTC (permalink / raw)
  To: devel; +Cc: Nickle Wang, Igor Kulchytskyy

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

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>
---
 .../Include/Library/RedfishHostInterfaceLib.h | 27 ++++++-
 .../PlatformHostInterfaceLibNull.c            | 26 ++++++-
 .../RedfishHostInterfaceDxe.c                 | 71 ++++++++++++++++++-
 3 files changed, 118 insertions(+), 6 deletions(-)

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


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

* Re: [PATCH V2 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification
  2022-12-19 14:51 [PATCH V2 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification Chang, Abner
@ 2022-12-19 15:11 ` Nickle Wang
       [not found] ` <17323A7141B7D8A4.29066@groups.io>
  2022-12-20 16:00 ` Igor Kulchytskyy
  2 siblings, 0 replies; 4+ messages in thread
From: Nickle Wang @ 2022-12-19 15:11 UTC (permalink / raw)
  To: abner.chang@amd.com, devel@edk2.groups.io; +Cc: Igor Kulchytskyy

Thanks for addressing my comment.

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

Regards,
Nickle

-----Original Message-----
From: abner.chang@amd.com <abner.chang@amd.com> 
Sent: Monday, December 19, 2022 10:51 PM
To: devel@edk2.groups.io
Cc: Nickle Wang <nicklew@nvidia.com>; Igor Kulchytskyy <igork@ami.com>
Subject: [PATCH V2 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification

External email: Use caution opening links or attachments


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

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>
---
 .../Include/Library/RedfishHostInterfaceLib.h | 27 ++++++-
 .../PlatformHostInterfaceLibNull.c            | 26 ++++++-
 .../RedfishHostInterfaceDxe.c                 | 71 ++++++++++++++++++-
 3 files changed, 118 insertions(+), 6 deletions(-)

diff --git a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
index 8d8389b9647..fa9f2d64eea 100644
--- a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
+++ b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
@@ -2,6 +2,7 @@
   Definitinos of RedfishHostInterfaceDxe driver.

   (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights 
+ reserved.<BR>

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

@@ -19,7 +20,7 @@
 /**
   Get platform Redfish host interface device descriptor.

-  @param[in] DeviceType         Pointer to retrieve device type.
+  @param[out] DeviceType        Pointer to retrieve device type.
   @param[out] DeviceDescriptor  Pointer to retrieve REDFISH_INTERFACE_DATA, caller has to free
                                 this memory using FreePool().
   @retval EFI_SUCCESS     Device descriptor is returned successfully in DeviceDescriptor.
@@ -28,7 +29,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8                    *DeviceType,
+  OUT UINT8                    *DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   );

@@ -40,7 +41,7 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
   @param[in, out] ProtocolRecord  Pointer to retrieve the first or the next protocol record.
                                   caller has to free the new protocol record returned from
                                   this function using FreePool().
-  param[in] IndexOfProtocolData   The index of protocol data.
+  @param[in] IndexOfProtocolData  The index of protocol data.

   @retval EFI_SUCCESS     Protocol records are all returned.
   @retval EFI_NOT_FOUND   No more protocol records.
@@ -52,4 +53,24 @@ RedfishPlatformHostInterfaceProtocolData (
   IN UINT8                                  IndexOfProtocolData
   );

+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+                                        GUID.
+
+  @retval EFI_SUCCESS          Notification is required for building up
+                               SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED      Notification is not required for building up
+                               SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others               Other errors.
+**/
+
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID **InformationReadinessGuid
+  );
 #endif
diff --git a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
index b30f9e37a4d..f83f5418d47 100644
--- a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
+++ b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterf
+++ aceLibNull.c
@@ -2,6 +2,7 @@
   NULL instace of RedfishPlatformHostInterfaceLib

   (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights 
+ reserved.<BR>

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

@@ -23,7 +24,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8                    *DeviceType,
+  OUT UINT8                    *DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   )
 {
@@ -51,3 +52,26 @@ RedfishPlatformHostInterfaceProtocolData (  {
   return EFI_NOT_FOUND;
 }
+
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+                                        GUID.
+
+  @retval EFI_SUCCESS          Notification is required for building up
+                               SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED      Notification is not required for building up
+                               SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others               Other errors.
+**/
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID **InformationReadinessGuid
+  )
+{
+  return EFI_UNSUPPORTED;
+}
diff --git a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
index 623350bc261..621b89fb847 100644
--- a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
+++ b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
@@ -6,6 +6,7 @@

   Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights 
+ reserved.<BR>

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

@@ -21,6 +22,9 @@
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/UefiRuntimeServicesTableLib.h>

+static EFI_EVENT mPlatformHostInterfaceReadylEvent = NULL; static VOID 
+*mPlatformHostInterfaceReadyRegistration = NULL;
+
 /**
   Create SMBIOS type 42 record for Redfish host interface.

@@ -238,6 +242,27 @@ ON_EXIT:
   return Status;
 }

+/**
+  Notification event of platform Redfish Host Interface readiness.
+
+  @param[in]  Event     Event whose notification function is being invoked.
+  @param[in]  Context   The pointer to the notification function's context,
+                        which is implementation-dependent.
+
+**/
+VOID
+EFIAPI
+PlatformHostInterfaceInformationReady (
+  IN  EFI_EVENT                Event,
+  IN  VOID                     *Context
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a: Platform Redfish Host Interface informtion 
+is ready\n", __FUNCTION__));
+
+  RedfishCreateSmbiosTable42 ();
+  return;
+}
+
 /**
   Main entry for this driver.

@@ -254,8 +279,50 @@ RedfishHostInterfaceDxeEntryPoint (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
+  EFI_STATUS Status;
+  EFI_GUID   *ReadyGuid;
+
+  DEBUG ((DEBUG_INFO, "%a: Entry\n.", __FUNCTION__));
+
   //
-  // Create SMBIOS type 42 record.
+  // Check if the Redfish Host Interface depends on  // the specific 
+ protocol installation.
   //
-  return RedfishCreateSmbiosTable42 ();
+  Status = RedfishPlatformHostInterfaceNotification (&ReadyGuid);  if 
+ (Status == EFI_SUCCESS) {
+     DEBUG ((DEBUG_INFO, "    Create protocol install notification to know the installation of platform Redfish host interface readiness\n"));
+     DEBUG ((DEBUG_INFO, "    Protocol GUID: %g\n", ReadyGuid));
+    //
+    // Register event for ReadyGuid protocol installed by
+    // platform Redfish host interface library.
+    //
+    Status = gBS->CreateEvent (
+                    EVT_NOTIFY_SIGNAL,
+                    TPL_CALLBACK,
+                    PlatformHostInterfaceInformationReady,
+                    NULL,
+                    &mPlatformHostInterfaceReadylEvent
+                    );
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "    Fail to create event for the installation of platform Redfish host interface readiness.\n"));
+      return Status;
+    }
+
+    Status = gBS->RegisterProtocolNotify (
+                    ReadyGuid,
+                    mPlatformHostInterfaceReadylEvent,
+                    &mPlatformHostInterfaceReadyRegistration
+                    );
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "    Fail to register event for the installation of platform Redfish host interface readiness.\n"));
+      return Status;
+    }
+    return EFI_SUCCESS;
+  }
+  if (Status == EFI_UNSUPPORTED || EFI_ALREADY_STARTED) {
+    Status = RedfishCreateSmbiosTable42 ();  }
+
+  // Return other erros.
+  return Status;
 }
--
2.37.1.windows.1


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

* Re: [edk2-devel] [PATCH V2 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification
       [not found] ` <17323A7141B7D8A4.29066@groups.io>
@ 2022-12-20  6:06   ` Nickle Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Nickle Wang @ 2022-12-20  6:06 UTC (permalink / raw)
  To: devel@edk2.groups.io, Nickle Wang, abner.chang@amd.com; +Cc: Igor Kulchytskyy

Hi Abner,

I found another bug as below.

+  if (Status == EFI_UNSUPPORTED || EFI_ALREADY_STARTED) {
+    Status = RedfishCreateSmbiosTable42 ();  

Second condition check miss "Status ==" and RedfishCreateSmbiosTable42() is always called in driver entry.

Thanks,
Nickle

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Nickle Wang via groups.io
Sent: Monday, December 19, 2022 11:11 PM
To: abner.chang@amd.com; devel@edk2.groups.io
Cc: Igor Kulchytskyy <igork@ami.com>
Subject: Re: [edk2-devel] [PATCH V2 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification

External email: Use caution opening links or attachments


Thanks for addressing my comment.

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

Regards,
Nickle

-----Original Message-----
From: abner.chang@amd.com <abner.chang@amd.com>
Sent: Monday, December 19, 2022 10:51 PM
To: devel@edk2.groups.io
Cc: Nickle Wang <nicklew@nvidia.com>; Igor Kulchytskyy <igork@ami.com>
Subject: [PATCH V2 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification

External email: Use caution opening links or attachments


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

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>
---
 .../Include/Library/RedfishHostInterfaceLib.h | 27 ++++++-
 .../PlatformHostInterfaceLibNull.c            | 26 ++++++-
 .../RedfishHostInterfaceDxe.c                 | 71 ++++++++++++++++++-
 3 files changed, 118 insertions(+), 6 deletions(-)

diff --git a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
index 8d8389b9647..fa9f2d64eea 100644
--- a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
+++ b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
@@ -2,6 +2,7 @@
   Definitinos of RedfishHostInterfaceDxe driver.

   (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights 
+ reserved.<BR>

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

@@ -19,7 +20,7 @@
 /**
   Get platform Redfish host interface device descriptor.

-  @param[in] DeviceType         Pointer to retrieve device type.
+  @param[out] DeviceType        Pointer to retrieve device type.
   @param[out] DeviceDescriptor  Pointer to retrieve REDFISH_INTERFACE_DATA, caller has to free
                                 this memory using FreePool().
   @retval EFI_SUCCESS     Device descriptor is returned successfully in DeviceDescriptor.
@@ -28,7 +29,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8                    *DeviceType,
+  OUT UINT8                    *DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   );

@@ -40,7 +41,7 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
   @param[in, out] ProtocolRecord  Pointer to retrieve the first or the next protocol record.
                                   caller has to free the new protocol record returned from
                                   this function using FreePool().
-  param[in] IndexOfProtocolData   The index of protocol data.
+  @param[in] IndexOfProtocolData  The index of protocol data.

   @retval EFI_SUCCESS     Protocol records are all returned.
   @retval EFI_NOT_FOUND   No more protocol records.
@@ -52,4 +53,24 @@ RedfishPlatformHostInterfaceProtocolData (
   IN UINT8                                  IndexOfProtocolData
   );

+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+                                        GUID.
+
+  @retval EFI_SUCCESS          Notification is required for building up
+                               SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED      Notification is not required for building up
+                               SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others               Other errors.
+**/
+
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID **InformationReadinessGuid
+  );
 #endif
diff --git a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
index b30f9e37a4d..f83f5418d47 100644
--- a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
+++ b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterf
+++ aceLibNull.c
@@ -2,6 +2,7 @@
   NULL instace of RedfishPlatformHostInterfaceLib

   (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights 
+ reserved.<BR>

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

@@ -23,7 +24,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8                    *DeviceType,
+  OUT UINT8                    *DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   )
 {
@@ -51,3 +52,26 @@ RedfishPlatformHostInterfaceProtocolData (  {
   return EFI_NOT_FOUND;
 }
+
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+                                        GUID.
+
+  @retval EFI_SUCCESS          Notification is required for building up
+                               SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED      Notification is not required for building up
+                               SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others               Other errors.
+**/
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID **InformationReadinessGuid
+  )
+{
+  return EFI_UNSUPPORTED;
+}
diff --git a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
index 623350bc261..621b89fb847 100644
--- a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
+++ b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
@@ -6,6 +6,7 @@

   Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights 
+ reserved.<BR>

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

@@ -21,6 +22,9 @@
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/UefiRuntimeServicesTableLib.h>

+static EFI_EVENT mPlatformHostInterfaceReadylEvent = NULL; static VOID 
+*mPlatformHostInterfaceReadyRegistration = NULL;
+
 /**
   Create SMBIOS type 42 record for Redfish host interface.

@@ -238,6 +242,27 @@ ON_EXIT:
   return Status;
 }

+/**
+  Notification event of platform Redfish Host Interface readiness.
+
+  @param[in]  Event     Event whose notification function is being invoked.
+  @param[in]  Context   The pointer to the notification function's context,
+                        which is implementation-dependent.
+
+**/
+VOID
+EFIAPI
+PlatformHostInterfaceInformationReady (
+  IN  EFI_EVENT                Event,
+  IN  VOID                     *Context
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a: Platform Redfish Host Interface informtion 
+is ready\n", __FUNCTION__));
+
+  RedfishCreateSmbiosTable42 ();
+  return;
+}
+
 /**
   Main entry for this driver.

@@ -254,8 +279,50 @@ RedfishHostInterfaceDxeEntryPoint (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
+  EFI_STATUS Status;
+  EFI_GUID   *ReadyGuid;
+
+  DEBUG ((DEBUG_INFO, "%a: Entry\n.", __FUNCTION__));
+
   //
-  // Create SMBIOS type 42 record.
+  // Check if the Redfish Host Interface depends on  // the specific 
+ protocol installation.
   //
-  return RedfishCreateSmbiosTable42 ();
+  Status = RedfishPlatformHostInterfaceNotification (&ReadyGuid);  if 
+ (Status == EFI_SUCCESS) {
+     DEBUG ((DEBUG_INFO, "    Create protocol install notification to know the installation of platform Redfish host interface readiness\n"));
+     DEBUG ((DEBUG_INFO, "    Protocol GUID: %g\n", ReadyGuid));
+    //
+    // Register event for ReadyGuid protocol installed by
+    // platform Redfish host interface library.
+    //
+    Status = gBS->CreateEvent (
+                    EVT_NOTIFY_SIGNAL,
+                    TPL_CALLBACK,
+                    PlatformHostInterfaceInformationReady,
+                    NULL,
+                    &mPlatformHostInterfaceReadylEvent
+                    );
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "    Fail to create event for the installation of platform Redfish host interface readiness.\n"));
+      return Status;
+    }
+
+    Status = gBS->RegisterProtocolNotify (
+                    ReadyGuid,
+                    mPlatformHostInterfaceReadylEvent,
+                    &mPlatformHostInterfaceReadyRegistration
+                    );
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "    Fail to register event for the installation of platform Redfish host interface readiness.\n"));
+      return Status;
+    }
+    return EFI_SUCCESS;
+  }
+  if (Status == EFI_UNSUPPORTED || EFI_ALREADY_STARTED) {
+    Status = RedfishCreateSmbiosTable42 ();  }
+
+  // Return other erros.
+  return Status;
 }
--
2.37.1.windows.1







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

* Re: [PATCH V2 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification
  2022-12-19 14:51 [PATCH V2 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification Chang, Abner
  2022-12-19 15:11 ` Nickle Wang
       [not found] ` <17323A7141B7D8A4.29066@groups.io>
@ 2022-12-20 16:00 ` Igor Kulchytskyy
  2 siblings, 0 replies; 4+ messages in thread
From: Igor Kulchytskyy @ 2022-12-20 16:00 UTC (permalink / raw)
  To: abner.chang@amd.com, devel@edk2.groups.io; +Cc: Nickle Wang

Reviewed-by: Igor Kulchytskyy <igork@ami.com>

-----Original Message-----
From: abner.chang@amd.com <abner.chang@amd.com>
Sent: Monday, December 19, 2022 9:51 AM
To: devel@edk2.groups.io
Cc: Nickle Wang <nicklew@nvidia.com>; Igor Kulchytskyy <igork@ami.com>
Subject: [EXTERNAL] [PATCH V2 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification


**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**

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

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>
---
 .../Include/Library/RedfishHostInterfaceLib.h | 27 ++++++-
 .../PlatformHostInterfaceLibNull.c            | 26 ++++++-
 .../RedfishHostInterfaceDxe.c                 | 71 ++++++++++++++++++-
 3 files changed, 118 insertions(+), 6 deletions(-)

diff --git a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
index 8d8389b9647..fa9f2d64eea 100644
--- a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
+++ b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
@@ -2,6 +2,7 @@
   Definitinos of RedfishHostInterfaceDxe driver.

   (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights
+ reserved.<BR>

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

@@ -19,7 +20,7 @@
 /**
   Get platform Redfish host interface device descriptor.

-  @param[in] DeviceType         Pointer to retrieve device type.
+  @param[out] DeviceType        Pointer to retrieve device type.
   @param[out] DeviceDescriptor  Pointer to retrieve REDFISH_INTERFACE_DATA, caller has to free
                                 this memory using FreePool().
   @retval EFI_SUCCESS     Device descriptor is returned successfully in DeviceDescriptor.
@@ -28,7 +29,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8                    *DeviceType,
+  OUT UINT8                    *DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   );

@@ -40,7 +41,7 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
   @param[in, out] ProtocolRecord  Pointer to retrieve the first or the next protocol record.
                                   caller has to free the new protocol record returned from
                                   this function using FreePool().
-  param[in] IndexOfProtocolData   The index of protocol data.
+  @param[in] IndexOfProtocolData  The index of protocol data.

   @retval EFI_SUCCESS     Protocol records are all returned.
   @retval EFI_NOT_FOUND   No more protocol records.
@@ -52,4 +53,24 @@ RedfishPlatformHostInterfaceProtocolData (
   IN UINT8                                  IndexOfProtocolData
   );

+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+                                        GUID.
+
+  @retval EFI_SUCCESS          Notification is required for building up
+                               SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED      Notification is not required for building up
+                               SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others               Other errors.
+**/
+
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID **InformationReadinessGuid
+  );
 #endif
diff --git a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
index b30f9e37a4d..f83f5418d47 100644
--- a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
+++ b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterf
+++ aceLibNull.c
@@ -2,6 +2,7 @@
   NULL instace of RedfishPlatformHostInterfaceLib

   (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights
+ reserved.<BR>

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

@@ -23,7 +24,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8                    *DeviceType,
+  OUT UINT8                    *DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   )
 {
@@ -51,3 +52,26 @@ RedfishPlatformHostInterfaceProtocolData (  {
   return EFI_NOT_FOUND;
 }
+
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+                                        GUID.
+
+  @retval EFI_SUCCESS          Notification is required for building up
+                               SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED      Notification is not required for building up
+                               SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others               Other errors.
+**/
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID **InformationReadinessGuid
+  )
+{
+  return EFI_UNSUPPORTED;
+}
diff --git a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
index 623350bc261..621b89fb847 100644
--- a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
+++ b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
@@ -6,6 +6,7 @@

   Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights
+ reserved.<BR>

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

@@ -21,6 +22,9 @@
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/UefiRuntimeServicesTableLib.h>

+static EFI_EVENT mPlatformHostInterfaceReadylEvent = NULL; static VOID
+*mPlatformHostInterfaceReadyRegistration = NULL;
+
 /**
   Create SMBIOS type 42 record for Redfish host interface.

@@ -238,6 +242,27 @@ ON_EXIT:
   return Status;
 }

+/**
+  Notification event of platform Redfish Host Interface readiness.
+
+  @param[in]  Event     Event whose notification function is being invoked.
+  @param[in]  Context   The pointer to the notification function's context,
+                        which is implementation-dependent.
+
+**/
+VOID
+EFIAPI
+PlatformHostInterfaceInformationReady (
+  IN  EFI_EVENT                Event,
+  IN  VOID                     *Context
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a: Platform Redfish Host Interface informtion
+is ready\n", __FUNCTION__));
+
+  RedfishCreateSmbiosTable42 ();
+  return;
+}
+
 /**
   Main entry for this driver.

@@ -254,8 +279,50 @@ RedfishHostInterfaceDxeEntryPoint (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
+  EFI_STATUS Status;
+  EFI_GUID   *ReadyGuid;
+
+  DEBUG ((DEBUG_INFO, "%a: Entry\n.", __FUNCTION__));
+
   //
-  // Create SMBIOS type 42 record.
+  // Check if the Redfish Host Interface depends on  // the specific
+ protocol installation.
   //
-  return RedfishCreateSmbiosTable42 ();
+  Status = RedfishPlatformHostInterfaceNotification (&ReadyGuid);  if
+ (Status == EFI_SUCCESS) {
+     DEBUG ((DEBUG_INFO, "    Create protocol install notification to know the installation of platform Redfish host interface readiness\n"));
+     DEBUG ((DEBUG_INFO, "    Protocol GUID: %g\n", ReadyGuid));
+    //
+    // Register event for ReadyGuid protocol installed by
+    // platform Redfish host interface library.
+    //
+    Status = gBS->CreateEvent (
+                    EVT_NOTIFY_SIGNAL,
+                    TPL_CALLBACK,
+                    PlatformHostInterfaceInformationReady,
+                    NULL,
+                    &mPlatformHostInterfaceReadylEvent
+                    );
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "    Fail to create event for the installation of platform Redfish host interface readiness.\n"));
+      return Status;
+    }
+
+    Status = gBS->RegisterProtocolNotify (
+                    ReadyGuid,
+                    mPlatformHostInterfaceReadylEvent,
+                    &mPlatformHostInterfaceReadyRegistration
+                    );
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "    Fail to register event for the installation of platform Redfish host interface readiness.\n"));
+      return Status;
+    }
+    return EFI_SUCCESS;
+  }
+  if (Status == EFI_UNSUPPORTED || EFI_ALREADY_STARTED) {
+    Status = RedfishCreateSmbiosTable42 ();  }
+
+  // Return other erros.
+  return Status;
 }
--
2.37.1.windows.1

-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.

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

end of thread, other threads:[~2022-12-20 16:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-19 14:51 [PATCH V2 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification Chang, Abner
2022-12-19 15:11 ` Nickle Wang
     [not found] ` <17323A7141B7D8A4.29066@groups.io>
2022-12-20  6:06   ` [edk2-devel] " Nickle Wang
2022-12-20 16:00 ` Igor Kulchytskyy

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