* [PATCH v2 RESEND] edk2-staging/RedfishClientPkg: Add Redfish.Settings support
[not found] <20221212083553.6407-1-simowang@nvidia.com>
@ 2022-12-12 8:37 ` Simon Wang (SW-GPU)
2022-12-12 8:41 ` Chang, Abner
0 siblings, 1 reply; 3+ messages in thread
From: Simon Wang (SW-GPU) @ 2022-12-12 8:37 UTC (permalink / raw)
To: devel@edk2.groups.io
Cc: Simon Wang (SW-GPU), Nickle Wang, Abner Chang, Igor Kulchytskyy,
Nick Ramirez
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/ComputerSystem
+++ Dxe.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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 RESEND] edk2-staging/RedfishClientPkg: Add Redfish.Settings support
@ 2022-12-12 8:39 Simon Wang
0 siblings, 0 replies; 3+ messages in thread
From: Simon Wang @ 2022-12-12 8:39 UTC (permalink / raw)
To: devel; +Cc: Nickle Wang, Abner Chang, Igor Kulchytskyy, Nick Ramirez
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 RESEND] edk2-staging/RedfishClientPkg: Add Redfish.Settings support
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
0 siblings, 0 replies; 3+ messages in thread
From: Chang, Abner @ 2022-12-12 8:41 UTC (permalink / raw)
To: Simon Wang (SW-GPU), devel@edk2.groups.io
Cc: Nickle Wang, Igor Kulchytskyy, Nick Ramirez
[AMD Official Use Only - General]
Reviewed-by: Abner Chang <abner.chang@amd.com>
> -----Original Message-----
> From: Simon Wang (SW-GPU) <simowang@nvidia.com>
> Sent: Monday, December 12, 2022 4:38 PM
> To: devel@edk2.groups.io
> Cc: Simon Wang (SW-GPU) <simowang@nvidia.com>; Nickle Wang
> <nicklew@nvidia.com>; Chang, Abner <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
>
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> 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/ComputerSystem
> Dxe.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_PROTOCO
> L(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_PROTOCO
> L (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_PROTOCO
> L (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/ComputerSyste
> mDxe.c
> b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSyst
> emDxe.c
> index c2a638d7c05c..5f8308b2bdeb 100644
> ---
> a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSyste
> mDxe.c
> +++
> b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSyst
> em
> +++ Dxe.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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-12 8:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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
2022-12-12 8:39 Simon Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox