From: Simon Wang <simowang@nvidia.com>
To: <devel@edk2.groups.io>
Cc: Nickle Wang <nicklew@nvidia.com>,
Abner Chang <abner.chang@amd.com>,
"Igor Kulchytskyy" <igork@ami.com>,
Nick Ramirez <nramirez@nvidia.com>
Subject: [PATCH v2 RESEND] edk2-staging/RedfishClientPkg: Add Redfish.Settings support
Date: Mon, 12 Dec 2022 08:39:46 +0000 [thread overview]
Message-ID: <20221212083946.6591-1-simowang@nvidia.com> (raw)
From: "Simon Wang" <simowang@nvidia.com>
BIOS feature driver cannot recognize "@Redfish.Settings",
decode it and get pending setting URI. So BIOS feature
driver can consume pending setting from correct place.
Signed-off-by: Simon Wang <simowang@nvidia.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Nick Ramirez <nramirez@nvidia.com>
---
RedfishClientPkg/Include/RedfishResourceCommon.h | 3 +
RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c | 216 ++++++++++++--------
RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c | 3 +-
RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c | 3 +-
4 files changed, 136 insertions(+), 89 deletions(-)
diff --git a/RedfishClientPkg/Include/RedfishResourceCommon.h b/RedfishClientPkg/Include/RedfishResourceCommon.h
index af4b8091215f..9c001206cbf0 100644
--- a/RedfishClientPkg/Include/RedfishResourceCommon.h
+++ b/RedfishClientPkg/Include/RedfishResourceCommon.h
@@ -2,6 +2,7 @@
Redfish feature driver common header file.
(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
+ Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -58,6 +59,8 @@ typedef struct _REDFISH_RESOURCE_COMMON_PRIVATE {
EFI_STRING RedfishVersion;
} REDFISH_RESOURCE_COMMON_PRIVATE;
+extern REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate;
+
#define REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_CONFIG_PROTOCOL(This) \
BASE_CR ((This), REDFISH_RESOURCE_COMMON_PRIVATE, ConfigHandler)
diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
index a478061cdeb6..909c7c0c09bb 100644
--- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
+++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
@@ -2,6 +2,7 @@
Redfish feature driver implementation - Bios
(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
+ Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -9,15 +10,13 @@
#include "../Common/BiosCommon.h"
-extern REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate;
-
EFI_STATUS
HandleResource (
- IN REDFISH_RESOURCE_COMMON_PRIVATE *Private,
- IN EFI_STRING Uri
+ IN REDFISH_RESOURCE_COMMON_PRIVATE *Private,
+ IN EFI_STRING Uri
);
-EFI_HANDLE medfishResourceConfigProtocolHandle;
+EFI_HANDLE medfishResourceConfigProtocolHandle;
/**
Provising redfish resource by given URI.
@@ -33,16 +32,16 @@ EFI_HANDLE medfishResourceConfigProtocolHandle;
**/
EFI_STATUS
RedfishResourceProvisioningResource (
- IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This,
- IN EFI_STRING Uri,
- IN BOOLEAN PostMode
+ IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This,
+ IN EFI_STRING Uri,
+ IN BOOLEAN PostMode
)
{
- REDFISH_RESOURCE_COMMON_PRIVATE *Private;
- EFI_STATUS Status;
- REDFISH_RESPONSE Response;
+ REDFISH_RESOURCE_COMMON_PRIVATE *Private;
+ EFI_STATUS Status;
+ REDFISH_RESPONSE Response;
- if (This == NULL || IS_EMPTY_STRING (Uri)) {
+ if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
return EFI_INVALID_PARAMETER;
}
@@ -60,7 +59,7 @@ RedfishResourceProvisioningResource (
return Status;
}
- Private->Uri = Uri;
+ Private->Uri = Uri;
Private->Payload = Response.Payload;
ASSERT (Private->Payload != NULL);
@@ -94,16 +93,22 @@ RedfishResourceProvisioningResource (
**/
EFI_STATUS
RedfishResourceConsumeResource (
- IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This,
- IN EFI_STRING Uri
+ IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This,
+ IN EFI_STRING Uri
)
{
- REDFISH_RESOURCE_COMMON_PRIVATE *Private;
- EFI_STATUS Status;
- REDFISH_RESPONSE Response;
- CHAR8 *Etag;
+ REDFISH_RESOURCE_COMMON_PRIVATE *Private;
+ EFI_STATUS Status;
+ REDFISH_RESPONSE Response;
+ REDFISH_RESPONSE *ExpectedResponse;
+ REDFISH_RESPONSE RedfishSettingsResponse;
+ CHAR8 *Etag;
+ UINTN Index;
+ EDKII_JSON_VALUE JsonValue;
+ EFI_STRING RedfishSettingsUri;
+ CONST CHAR8 *RedfishSettingsUriKeys[] = { "@Redfish.Settings", "SettingsObject", "@odata.id" };
- if (This == NULL || IS_EMPTY_STRING (Uri)) {
+ if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
return EFI_INVALID_PARAMETER;
}
@@ -119,8 +124,38 @@ RedfishResourceConsumeResource (
return Status;
}
- Private->Uri = Uri;
- Private->Payload = Response.Payload;
+ ExpectedResponse = &Response;
+ RedfishSettingsUri = NULL;
+ JsonValue = RedfishJsonInPayload (Response.Payload);
+
+ //
+ // Seeking RedfishSettings URI link.
+ //
+ for (Index = 0; Index < ARRAY_SIZE (RedfishSettingsUriKeys); Index++) {
+ if (JsonValue == NULL) {
+ break;
+ }
+
+ JsonValue = JsonObjectGetValue (JsonValueGetObject (JsonValue), RedfishSettingsUriKeys[Index]);
+ }
+
+ if (JsonValue != NULL) {
+ //
+ // Verify RedfishSettings URI link is valid to retrieve resource or not.
+ //
+ RedfishSettingsUri = JsonValueGetUnicodeString (JsonValue);
+
+ Status = GetResourceByUri (Private->RedfishService, RedfishSettingsUri, &RedfishSettingsResponse);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a, @Redfish.Settings exists, get resource from: %s failed\n", __FUNCTION__, RedfishSettingsUri));
+ } else {
+ Uri = RedfishSettingsUri;
+ ExpectedResponse = &RedfishSettingsResponse;
+ }
+ }
+
+ Private->Uri = Uri;
+ Private->Payload = ExpectedResponse->Payload;
ASSERT (Private->Payload != NULL);
Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload), EDKII_JSON_COMPACT);
@@ -129,8 +164,8 @@ RedfishResourceConsumeResource (
//
// Find etag in HTTP response header
//
- Etag = NULL;
- Status = GetEtagAndLocation (&Response, &Etag, NULL);
+ Etag = NULL;
+ Status = GetEtagAndLocation (ExpectedResponse, &Etag, NULL);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n", __FUNCTION__));
}
@@ -153,12 +188,24 @@ RedfishResourceConsumeResource (
// Release resource
//
if (Private->Payload != NULL) {
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
+ if (Response.Payload != NULL) {
+ RedfishFreeResponse (
+ Response.StatusCode,
+ Response.HeaderCount,
+ Response.Headers,
+ Response.Payload
+ );
+ }
+
+ if (RedfishSettingsResponse.Payload != NULL) {
+ RedfishFreeResponse (
+ RedfishSettingsResponse.StatusCode,
+ RedfishSettingsResponse.HeaderCount,
+ RedfishSettingsResponse.Headers,
+ RedfishSettingsResponse.Payload
+ );
+ }
+
Private->Payload = NULL;
}
@@ -185,13 +232,13 @@ RedfishResourceConsumeResource (
**/
EFI_STATUS
RedfishResourceGetInfo (
- IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This,
+ IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This,
OUT REDFISH_SCHEMA_INFO *Info
)
{
- REDFISH_RESOURCE_COMMON_PRIVATE *Private;
+ REDFISH_RESOURCE_COMMON_PRIVATE *Private;
- if (This == NULL || Info == NULL) {
+ if ((This == NULL) || (Info == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -217,15 +264,15 @@ RedfishResourceGetInfo (
**/
EFI_STATUS
RedfishResourceUpdate (
- IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This,
- IN EFI_STRING Uri
+ IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This,
+ IN EFI_STRING Uri
)
{
- REDFISH_RESOURCE_COMMON_PRIVATE *Private;
- EFI_STATUS Status;
- REDFISH_RESPONSE Response;
+ REDFISH_RESOURCE_COMMON_PRIVATE *Private;
+ EFI_STATUS Status;
+ REDFISH_RESPONSE Response;
- if (This == NULL || IS_EMPTY_STRING (Uri)) {
+ if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
return EFI_INVALID_PARAMETER;
}
@@ -241,7 +288,7 @@ RedfishResourceUpdate (
return Status;
}
- Private->Uri = Uri;
+ Private->Uri = Uri;
Private->Payload = Response.Payload;
ASSERT (Private->Payload != NULL);
@@ -286,15 +333,15 @@ RedfishResourceUpdate (
**/
EFI_STATUS
RedfishResourceCheck (
- IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This,
- IN EFI_STRING Uri
+ IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This,
+ IN EFI_STRING Uri
)
{
- REDFISH_RESOURCE_COMMON_PRIVATE *Private;
- EFI_STATUS Status;
- REDFISH_RESPONSE Response;
+ REDFISH_RESOURCE_COMMON_PRIVATE *Private;
+ EFI_STATUS Status;
+ REDFISH_RESPONSE Response;
- if (This == NULL || IS_EMPTY_STRING (Uri)) {
+ if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
return EFI_INVALID_PARAMETER;
}
@@ -310,7 +357,7 @@ RedfishResourceCheck (
return Status;
}
- Private->Uri = Uri;
+ Private->Uri = Uri;
Private->Payload = Response.Payload;
ASSERT (Private->Payload != NULL);
@@ -354,18 +401,17 @@ RedfishResourceCheck (
@retval Others Some error happened.
**/
-
EFI_STATUS
RedfishResourceIdentify (
IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This,
IN EFI_STRING Uri
)
{
- REDFISH_RESOURCE_COMMON_PRIVATE *Private;
- EFI_STATUS Status;
- REDFISH_RESPONSE Response;
+ REDFISH_RESOURCE_COMMON_PRIVATE *Private;
+ EFI_STATUS Status;
+ REDFISH_RESPONSE Response;
- if (This == NULL || IS_EMPTY_STRING (Uri)) {
+ if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
return EFI_INVALID_PARAMETER;
}
@@ -381,7 +427,7 @@ RedfishResourceIdentify (
return Status;
}
- Private->Uri = Uri;
+ Private->Uri = Uri;
Private->Payload = Response.Payload;
ASSERT (Private->Payload != NULL);
@@ -392,6 +438,7 @@ RedfishResourceIdentify (
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, identify %s failed: %r\n", __FUNCTION__, Uri, Status));
}
+
//
// Release resource
//
@@ -413,7 +460,7 @@ RedfishResourceIdentify (
return Status;
}
-EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL mRedfishResourceConfig = {
+EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL mRedfishResourceConfig = {
RedfishResourceProvisioningResource,
RedfishResourceConsumeResource,
RedfishResourceUpdate,
@@ -441,10 +488,10 @@ EFI_STATUS
EFIAPI
RedfishResourceInit (
IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This,
- IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo
+ IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo
)
{
- REDFISH_RESOURCE_COMMON_PRIVATE *Private;
+ REDFISH_RESOURCE_COMMON_PRIVATE *Private;
Private = REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_CONFIG_PROTOCOL (This);
@@ -468,10 +515,10 @@ RedfishResourceInit (
EFI_STATUS
EFIAPI
RedfishResourceStop (
- IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This
+ IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This
)
{
- REDFISH_RESOURCE_COMMON_PRIVATE *Private;
+ REDFISH_RESOURCE_COMMON_PRIVATE *Private;
Private = REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_CONFIG_PROTOCOL (This);
@@ -493,7 +540,7 @@ RedfishResourceStop (
return EFI_SUCCESS;
}
-EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL mRedfishConfigHandler = {
+EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL mRedfishConfigHandler = {
RedfishResourceInit,
RedfishResourceStop
};
@@ -506,10 +553,9 @@ EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL mRedfishConfigHandler = {
**/
VOID
EFIAPI
-EfiRestJasonStructureProtocolIsReady
- (
- IN EFI_EVENT Event,
- IN VOID *Context
+EfiRestJasonStructureProtocolIsReady (
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
EFI_STATUS Status;
@@ -523,10 +569,10 @@ EfiRestJasonStructureProtocolIsReady
}
Status = gBS->LocateProtocol (
- &gEfiRestJsonStructureProtocolGuid,
- NULL,
- (VOID **)&mRedfishResourcePrivate->JsonStructProtocol
- );
+ &gEfiRestJsonStructureProtocolGuid,
+ NULL,
+ (VOID **)&mRedfishResourcePrivate->JsonStructProtocol
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, failed to locate gEfiRestJsonStructureProtocolGuid: %r\n", __FUNCTION__, Status));
}
@@ -550,7 +596,7 @@ RedfishResourceUnload (
)
{
EFI_STATUS Status;
- EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *ConfigHandler;
+ EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *ConfigHandler;
if (mRedfishResourcePrivate == NULL) {
return EFI_NOT_READY;
@@ -564,12 +610,12 @@ RedfishResourceUnload (
Status = gBS->OpenProtocol (
ImageHandle,
&gEdkIIRedfishConfigHandlerProtocolGuid,
- (VOID **) &ConfigHandler,
+ (VOID **)&ConfigHandler,
NULL,
NULL,
EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL
);
- if (EFI_ERROR (Status) || ConfigHandler == NULL) {
+ if (EFI_ERROR (Status) || (ConfigHandler == NULL)) {
return Status;
}
@@ -612,10 +658,10 @@ RedfishResourceUnload (
EFI_STATUS
EFIAPI
RedfishExternalResourceResourceFeatureCallback (
- IN EDKII_REDFISH_FEATURE_PROTOCOL *This,
- IN FEATURE_CALLBACK_ACTION FeatureAction,
- IN VOID *Context,
- IN OUT RESOURCE_INFORMATION_EXCHANGE *InformationExchange
+ IN EDKII_REDFISH_FEATURE_PROTOCOL *This,
+ IN FEATURE_CALLBACK_ACTION FeatureAction,
+ IN VOID *Context,
+ IN OUT RESOURCE_INFORMATION_EXCHANGE *InformationExchange
)
{
EFI_STATUS Status;
@@ -647,11 +693,12 @@ RedfishExternalResourceResourceFeatureCallback (
//
// Create the full URI from Redfish service root.
//
- ResourceUri = (EFI_STRING)AllocateZeroPool (MAX_URI_LENGTH * sizeof(CHAR16));
+ ResourceUri = (EFI_STRING)AllocateZeroPool (MAX_URI_LENGTH * sizeof (CHAR16));
if (ResourceUri == NULL) {
DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for full URI.\n", __FUNCTION__));
return EFI_OUT_OF_RESOURCES;
}
+
StrCatS (ResourceUri, MAX_URI_LENGTH, Private->RedfishVersion);
StrCatS (ResourceUri, MAX_URI_LENGTH, InformationExchange->SendInformation.FullUri);
@@ -681,10 +728,9 @@ RedfishExternalResourceResourceFeatureCallback (
**/
VOID
EFIAPI
-EdkIIRedfishFeatureProtocolIsReady
- (
- IN EFI_EVENT Event,
- IN VOID *Context
+EdkIIRedfishFeatureProtocolIsReady (
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
EFI_STATUS Status;
@@ -699,10 +745,10 @@ EdkIIRedfishFeatureProtocolIsReady
}
Status = gBS->LocateProtocol (
- &gEdkIIRedfishFeatureProtocolGuid,
- NULL,
- (VOID **)&FeatureProtocol
- );
+ &gEdkIIRedfishFeatureProtocolGuid,
+ NULL,
+ (VOID **)&FeatureProtocol
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, failed to locate gEdkIIRedfishFeatureProtocolGuid: %r\n", __FUNCTION__, Status));
gBS->CloseEvent (Event);
@@ -744,8 +790,8 @@ RedfishResourceEntryPoint (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- VOID *Registration;
+ EFI_STATUS Status;
+ VOID *Registration;
if (mRedfishResourcePrivate != NULL) {
return EFI_ALREADY_STARTED;
diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c
index c2a638d7c05c..5f8308b2bdeb 100644
--- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c
+++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c
@@ -2,6 +2,7 @@
Redfish feature driver implementation - ComputerSystem
(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
+ Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -9,8 +10,6 @@
#include "../Common/ComputerSystemCommon.h"
-extern REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate;
-
EFI_HANDLE medfishResourceConfigProtocolHandle;
/**
diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
index 0a9d344d6fe7..e43828f628fa 100644
--- a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
+++ b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
@@ -2,6 +2,7 @@
Redfish feature driver implementation - Memory
(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
+ Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -9,8 +10,6 @@
#include "../Common/MemoryCommon.h"
-extern REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate;
-
EFI_HANDLE medfishResourceConfigProtocolHandle;
/**
--
2.17.1
next reply other threads:[~2022-12-12 8:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-12 8:39 Simon Wang [this message]
[not found] <20221212083553.6407-1-simowang@nvidia.com>
2022-12-12 8:37 ` [PATCH v2 RESEND] edk2-staging/RedfishClientPkg: Add Redfish.Settings support Simon Wang (SW-GPU)
2022-12-12 8:41 ` 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=20221212083946.6591-1-simowang@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