From: "Nickle Wang" <nicklew@nvidia.com>
To: <devel@edk2.groups.io>
Cc: Abner Chang <abner.chang@amd.com>, Igor Kulchytskyy <igork@ami.com>
Subject: [edk2-redfish-client][PATCH 3/4] RedfishClientPkg: Add mechanism to reboot system if config is changed
Date: Fri, 12 May 2023 11:47:17 +0800 [thread overview]
Message-ID: <20230512034717.8627-1-nicklew@nvidia.com> (raw)
When system configuration is updated from RESTful interface, we need a
system reboot so that the changes can be applied. Introduce PCD
"PcdSystemRebootRequired" to RedfishClientPkg. RedfishFeatureUtility
library will enable this flag when system config is updated.
RedfishFeatureCore driver will check this flag and perform cold reboot
after all Redfish operations are finished. PCD "PcdSystemRebootTimeout"
is used to specify how many second BIOS will wait before reboot system.
Signed-off-by: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
---
RedfishClientPkg/RedfishClientPkg.dec | 8 ++-
.../RedfishFeatureUtilityLib.inf | 3 +
.../RedfishFeatureCoreDxe.inf | 5 ++
.../Library/RedfishFeatureUtilityLib.h | 3 +
.../RedfishFeatureCoreDxe.h | 3 +
.../RedfishFeatureUtilityLib.c | 65 ++++++++++++++++---
.../RedfishFeatureCoreDxe.c | 40 +++++++++---
7 files changed, 106 insertions(+), 21 deletions(-)
diff --git a/RedfishClientPkg/RedfishClientPkg.dec b/RedfishClientPkg/RedfishClientPkg.dec
index d3c97ecf..c0ab30ab 100644
--- a/RedfishClientPkg/RedfishClientPkg.dec
+++ b/RedfishClientPkg/RedfishClientPkg.dec
@@ -2,7 +2,7 @@
# Redfish Client Package
#
# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR>
-# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
@@ -65,3 +65,9 @@
gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupEventGuid|{0xB3, 0x8F, 0xE8, 0x7C, 0xD7, 0x4B, 0x79, 0x46, 0x87, 0xA8, 0xA8, 0xD8, 0xDE, 0xE5, 0x0D, 0x2B}|VOID*|0x10000003
## Default Redfish version string
gEfiRedfishClientPkgTokenSpaceGuid.PcdDefaultRedfishVersion|L"v1"|VOID*|0x10000004
+ ## The number of seconds that the firmware will wait before system reboot
+ gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootTimeout|5|UINT16|0x20000002
+
+[PcdsDynamicEx]
+ ## The flag used to indicate that system reboot is required due to system configuration change
+ gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootRequired|FALSE|BOOLEAN|0x20000001
diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf
index 84f338e6..66d5dce6 100644
--- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf
+++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf
@@ -1,6 +1,8 @@
## @file
+# INF for Redfish feature utility library.
#
# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
+# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -49,6 +51,7 @@
gEdkIIRedfishConfigLangMapProtocolGuid ## CONSUMED ##
[Pcd]
+ gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootRequired
[Guids]
diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
index ddcf9910..c67525ee 100644
--- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
+++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
@@ -4,6 +4,8 @@
# drivers for the registration.
#
# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR>
+# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
@@ -40,6 +42,7 @@
RedfishFeatureUtilityLib
UefiBootServicesTableLib
UefiDriverEntryPoint
+ UefiRuntimeServicesTableLib
UefiLib
[Protocols]
@@ -47,6 +50,8 @@
[Pcd]
gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupEventGuid
+ gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootRequired
+ gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootTimeout
[Depex]
TRUE
diff --git a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
index d2733476..14296432 100644
--- a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
+++ b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
@@ -2,6 +2,7 @@
This file defines the Redfish Feature Utility Library interface.
(C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR>
+ Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -14,6 +15,8 @@
#include <Protocol/EdkIIRedfishPlatformConfig.h>
#include <RedfishJsonStructure/RedfishCsCommon.h>
+#define REDFISH_ENABLE_SYSTEM_REBOOT() PcdSetBoolS(PcdRedfishSystemRebootRequired, TRUE)
+
//
// Definition of REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG
//
diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h
index ff3c787a..a94c7930 100644
--- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h
+++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h
@@ -2,6 +2,7 @@
Definitions of RedfishFeatureCoreDxe
(C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR>
+ Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -18,6 +19,8 @@
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/RedfishEventLib.h>
#include <Library/RedfishFeatureUtilityLib.h>
diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
index e87af3d5..ed8a021c 100644
--- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
+++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
@@ -2,7 +2,7 @@
Redfish feature utility library implementation
(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
- Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -323,7 +323,12 @@ ApplyFeatureSettingsStringType (
RedfishValue.Value.Buffer = FeatureValue;
Status = RedfishPlatformConfigSetValue (Schema, Version, ConfigureLang, RedfishValue);
- if (EFI_ERROR (Status)) {
+ if (!EFI_ERROR (Status)) {
+ //
+ // Configuration changed. Enable system reboot flag.
+ //
+ REDFISH_ENABLE_SYSTEM_REBOOT ();
+ } else {
DEBUG ((DEBUG_ERROR, "%a, apply %s to %s failed: %r\n", __FUNCTION__, ConfigureLang, FeatureValue, Status));
}
} else {
@@ -383,7 +388,12 @@ ApplyFeatureSettingsNumericType (
RedfishValue.Value.Integer = (INT64)FeatureValue;
Status = RedfishPlatformConfigSetValue (Schema, Version, ConfigureLang, RedfishValue);
- if (EFI_ERROR (Status)) {
+ if (!EFI_ERROR (Status)) {
+ //
+ // Configuration changed. Enable system reboot flag.
+ //
+ REDFISH_ENABLE_SYSTEM_REBOOT ();
+ } else {
DEBUG ((DEBUG_ERROR, "%a, apply %s to 0x%x failed: %r\n", __FUNCTION__, ConfigureLang, FeatureValue, Status));
}
} else {
@@ -443,7 +453,12 @@ ApplyFeatureSettingsBooleanType (
RedfishValue.Value.Boolean = FeatureValue;
Status = RedfishPlatformConfigSetValue (Schema, Version, ConfigureLang, RedfishValue);
- if (EFI_ERROR (Status)) {
+ if (!EFI_ERROR (Status)) {
+ //
+ // Configuration changed. Enable system reboot flag.
+ //
+ REDFISH_ENABLE_SYSTEM_REBOOT ();
+ } else {
DEBUG ((DEBUG_ERROR, "%a, apply %s to %a failed: %r\n", __FUNCTION__, ConfigureLang, (FeatureValue ? "True" : "False"), Status));
}
} else {
@@ -561,7 +576,12 @@ ApplyFeatureSettingsVagueType (
FreePool (RedfishValue.Value.Buffer);
RedfishValue.Value.Buffer = CurrentVagueValuePtr->Value->DataValue.CharPtr;
Status = RedfishPlatformConfigSetValue (Schema, Version, ConfigureKeyLang, RedfishValue);
- if (EFI_ERROR (Status)) {
+ if (!EFI_ERROR (Status)) {
+ //
+ // Configuration changed. Enable system reboot flag.
+ //
+ REDFISH_ENABLE_SYSTEM_REBOOT ();
+ } else {
DEBUG ((DEBUG_ERROR, "%a, apply %a to %a failed: %r\n", __FUNCTION__, ConfigureKeyLang, CurrentVagueValuePtr->Value->DataValue.CharPtr, Status));
}
} else {
@@ -588,7 +608,12 @@ ApplyFeatureSettingsVagueType (
RedfishValue.Value.Boolean = (BOOLEAN)*CurrentVagueValuePtr->Value->DataValue.BoolPtr;
Status = RedfishPlatformConfigSetValue (Schema, Version, ConfigureKeyLang, RedfishValue);
- if (EFI_ERROR (Status)) {
+ if (!EFI_ERROR (Status)) {
+ //
+ // Configuration changed. Enable system reboot flag.
+ //
+ REDFISH_ENABLE_SYSTEM_REBOOT ();
+ } else {
DEBUG ((DEBUG_ERROR, "%a, apply %s to %a failed: %r\n", __FUNCTION__, ConfigureKeyLang, (*CurrentVagueValuePtr->Value->DataValue.BoolPtr ? "True" : "False"), Status));
}
} else {
@@ -606,7 +631,12 @@ ApplyFeatureSettingsVagueType (
RedfishValue.Value.Integer = (INT64)*CurrentVagueValuePtr->Value->DataValue.Int64Ptr;
Status = RedfishPlatformConfigSetValue (Schema, Version, ConfigureKeyLang, RedfishValue);
- if (EFI_ERROR (Status)) {
+ if (!EFI_ERROR (Status)) {
+ //
+ // Configuration changed. Enable system reboot flag.
+ //
+ REDFISH_ENABLE_SYSTEM_REBOOT ();
+ } else {
DEBUG ((DEBUG_ERROR, "%a, apply %s to 0x%x failed: %r\n", __FUNCTION__, ConfigureKeyLang, *CurrentVagueValuePtr->Value->DataValue.Int64Ptr, Status));
}
} else {
@@ -783,7 +813,12 @@ ApplyFeatureSettingsStringArrayType (
ASSERT (Index <= RedfishValue.ArrayCount);
Status = RedfishPlatformConfigSetValue (Schema, Version, ConfigureLang, RedfishValue);
- if (EFI_ERROR (Status)) {
+ if (!EFI_ERROR (Status)) {
+ //
+ // Configuration changed. Enable system reboot flag.
+ //
+ REDFISH_ENABLE_SYSTEM_REBOOT ();
+ } else {
DEBUG ((DEBUG_ERROR, "%a, apply %s array failed: %r\n", __FUNCTION__, ConfigureLang, Status));
}
} else {
@@ -876,7 +911,12 @@ ApplyFeatureSettingsNumericArrayType (
ASSERT (Index <= RedfishValue.ArrayCount);
Status = RedfishPlatformConfigSetValue (Schema, Version, ConfigureLang, RedfishValue);
- if (EFI_ERROR (Status)) {
+ if (!EFI_ERROR (Status)) {
+ //
+ // Configuration changed. Enable system reboot flag.
+ //
+ REDFISH_ENABLE_SYSTEM_REBOOT ();
+ } else {
DEBUG ((DEBUG_ERROR, "%a, apply %s array failed: %r\n", __FUNCTION__, ConfigureLang, Status));
}
} else {
@@ -969,7 +1009,12 @@ ApplyFeatureSettingsBooleanArrayType (
ASSERT (Index <= RedfishValue.ArrayCount);
Status = RedfishPlatformConfigSetValue (Schema, Version, ConfigureLang, RedfishValue);
- if (EFI_ERROR (Status)) {
+ if (!EFI_ERROR (Status)) {
+ //
+ // Configuration changed. Enable system reboot flag.
+ //
+ REDFISH_ENABLE_SYSTEM_REBOOT ();
+ } else {
DEBUG ((DEBUG_ERROR, "%a, apply %s array failed: %r\n", __FUNCTION__, ConfigureLang, Status));
}
} else {
diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c
index 0e513b16..5a3a9e4c 100644
--- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c
+++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c
@@ -3,6 +3,7 @@
for EDK2 Redfish Feature driver registration.
(C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR>
+ Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -13,13 +14,14 @@
EFI_EVENT mEdkIIRedfishFeatureDriverStartupEvent;
REDFISH_FEATURE_STARTUP_CONTEXT mFeatureDriverStartupContext;
REDFISH_FEATURE_INTERNAL_DATA *ResourceUriNodeList;
-
-RESOURCE_INFORMATION_EXCHANGE *mInformationExchange;
+RESOURCE_INFORMATION_EXCHANGE *mInformationExchange;
/**
Setup the information to deliver to child feature/collection driver.
+
@param[in] ThisList REDFISH_FEATURE_INTERNAL_DATA instance.
@param[in] ParentConfgLanguageUri Parent configure language URI.
+
**/
EFI_STATUS
SetupExchangeInformationInfo (
@@ -70,7 +72,9 @@ SetupExchangeInformationInfo (
/**
Destroy the exchange information.
+
@param[in] ThisList REDFISH_FEATURE_INTERNAL_DATA instance.
+
**/
EFI_STATUS
DestroryExchangeInformation (
@@ -239,8 +243,10 @@ RedfishFeatureDriverStartup (
)
{
REDFISH_FEATURE_STARTUP_CONTEXT *StartupContext;
+ UINT16 RebootTimeout;
StartupContext = (REDFISH_FEATURE_STARTUP_CONTEXT *)Context;
+ RebootTimeout = PcdGet16 (PcdRedfishSystemRebootTimeout);
//
// Invoke EDK2 Redfish feature driver callback to start up
// the Redfish operations.
@@ -258,6 +264,11 @@ RedfishFeatureDriverStartup (
return;
}
+ //
+ // Reset PcdRedfishSystemRebootRequired flag
+ //
+ PcdSetBoolS (PcdRedfishSystemRebootRequired, FALSE);
+
//
// Signal event before doing provisioning
//
@@ -272,6 +283,16 @@ RedfishFeatureDriverStartup (
// Signal event after provisioning finished
//
SignalAfterProvisioningEvent ();
+
+ //
+ // If system configuration is changed, reboot system.
+ //
+ if (PcdGetBool (PcdRedfishSystemRebootRequired)) {
+ Print (L"System configuration is changed from RESTful interface. Reboot system in %d seconds...\n", RebootTimeout);
+ gBS->Stall (RebootTimeout * 1000000U);
+ gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
+ CpuDeadLoop ();
+ }
}
/**
@@ -298,14 +319,14 @@ NewInternalInstance (
REDFISH_FEATURE_INTERNAL_DATA *NewInternalData;
if ((PtrToNewInternalData == NULL) || (NodeName == NULL)) {
- DEBUG ((DEBUG_ERROR, "%a: Inproper given parameters\n", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: Inproper given parameters\n", __FUNCTION__));
return EFI_INVALID_PARAMETER;
}
*PtrToNewInternalData = NULL;
NewInternalData = AllocateZeroPool (sizeof (REDFISH_FEATURE_INTERNAL_DATA));
if (NewInternalData == NULL) {
- DEBUG ((DEBUG_ERROR, "%a: No memory for REDFISH_FEATURE_INTERNAL_DATA\n", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: No memory for REDFISH_FEATURE_INTERNAL_DATA\n", __FUNCTION__));
return EFI_OUT_OF_RESOURCES;
}
@@ -334,7 +355,6 @@ NewInternalInstance (
The returned LIST_ENTRY is the address of
ChildList link list.
@param[out] MatchNodeEntry The matched node entry.
-
@retval EFI_SUCCESS New entry is inserted successfully.
@retval EFI_INVALID_PARAMETER Improper given parameters.
@retval EFI_OUT_OF_RESOURCES Lack of memory for the internal data structure.
@@ -357,12 +377,12 @@ InsertRedfishFeatureUriNode (
*MatchNodeEntry = NULL;
if (NodeName == NULL) {
- DEBUG ((DEBUG_ERROR, "%a: Node name is NULL.\n", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: Node name is NULL.\n", __FUNCTION__));
return EFI_INVALID_PARAMETER;
}
if (NextNodeEntry == NULL) {
- DEBUG ((DEBUG_ERROR, "%a: NextNodeEntry can't be NULL.\n", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: NextNodeEntry can't be NULL.\n", __FUNCTION__));
return EFI_INVALID_PARAMETER;
}
@@ -467,7 +487,7 @@ RedfishFeatureRegister (
BOOLEAN ItsCollection;
if ((FeatureManagedUri == NULL) || (Callback == NULL)) {
- DEBUG ((DEBUG_ERROR, "%a: The given parameter is invalid\n", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: The given parameter is invalid\n", __FUNCTION__));
return EFI_INVALID_PARAMETER;
}
@@ -483,7 +503,7 @@ RedfishFeatureRegister (
while ((Index < UriLength)) {
if ((Index - AnchorIndex + 1) >= MaxNodeNameLength) {
// Increase one for the NULL terminator
- DEBUG ((DEBUG_ERROR, "%a: the length of node name is >= MaxNodeNameLength\n", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: the length of node name is >= MaxNodeNameLength\n", __FUNCTION__));
ASSERT (FALSE);
}
@@ -548,7 +568,7 @@ RedfishFeatureRegister (
//
// No URI node was created
//
- DEBUG ((DEBUG_ERROR, "%a: No URI node is added\n", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: No URI node is added\n", __FUNCTION__));
return EFI_INVALID_PARAMETER;
}
--
2.17.1
next reply other threads:[~2023-05-12 3:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-12 3:47 Nickle Wang [this message]
2023-05-12 4:12 ` [edk2-redfish-client][PATCH 3/4] RedfishClientPkg: Add mechanism to reboot system if config is changed 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=20230512034717.8627-1-nicklew@nvidia.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