Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting object config lang #84

Merged
merged 2 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ RedfishResourceConsumeResource (
);
if (!EFI_ERROR (Status)) {
DEBUG ((REDFISH_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n", __func__, PendingSettingUri));
SetRedfishSettingsObjectsUri (Private->Uri, PendingSettingUri);
Private->Uri = PendingSettingUri;
ExpectedResponse = &PendingSettingResponse;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ RedfishResourceConsumeResource (
);
if (!EFI_ERROR (Status)) {
DEBUG ((REDFISH_BOOT_OPTION_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n", __func__, PendingSettingUri));
SetRedfishSettingsObjectsUri (Private->Uri, PendingSettingUri);
Private->Uri = PendingSettingUri;
ExpectedResponse = &PendingSettingResponse;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ RedfishResourceConsumeResource (
);
if (!EFI_ERROR (Status)) {
DEBUG ((REDFISH_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n", __func__, PendingSettingUri));
SetRedfishSettingsObjectsUri (Private->Uri, PendingSettingUri);
Private->Uri = PendingSettingUri;
ExpectedResponse = &PendingSettingResponse;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ RedfishResourceConsumeResource (
);
if (!EFI_ERROR (Status)) {
DEBUG ((REDFISH_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n", __func__, PendingSettingUri));
SetRedfishSettingsObjectsUri (Private->Uri, PendingSettingUri);
Private->Uri = PendingSettingUri;
ExpectedResponse = &PendingSettingResponse;
} else {
Expand Down
1 change: 1 addition & 0 deletions RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ RedfishResourceConsumeResource (
);
if (!EFI_ERROR (Status)) {
DEBUG ((REDFISH_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n", __func__, PendingSettingUri));
SetRedfishSettingsObjectsUri (Private->Uri, PendingSettingUri);
Private->Uri = PendingSettingUri;
ExpectedResponse = &PendingSettingResponse;
} else {
Expand Down
17 changes: 17 additions & 0 deletions RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,23 @@ RedfishSetRedfishUri (
IN EFI_STRING Uri
);

/**

Save Redfish SettingsObject URI in database for further use.

@param[in] ParentUri Parent URI of @Redfish.Settings property.
@param[in] SettingObjectUri Redfish SettingsObject Uri to save.

@retval EFI_INVALID_PARAMETER SystemId is NULL or EMPTY
@retval EFI_SUCCESS Redfish uri is saved

**/
EFI_STATUS
SetRedfishSettingsObjectsUri (
IN EFI_STRING ParentUri,
IN EFI_STRING SettingObjectUri
);

/**

Get the property name by given Configure Language.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,6 @@ GetConfigureLang (
EFI_STRING ResultStr;
EFI_STRING UnicodeUri;
EFI_STATUS Status;
EFI_STRING StrFound;

if (IS_EMPTY_STRING (Uri)) {
return NULL;
Expand All @@ -2101,18 +2100,6 @@ GetConfigureLang (
}

ConfigLang = RedfishGetConfigLanguage (UnicodeUri);
if (ConfigLang == NULL) {
//
// @Redfish.Settings share the same schema as its parent.
// Remove "Settings" and try again.
//
StrFound = StrStr (UnicodeUri, L"/Settings");
if (StrFound != NULL) {
StrFound[0] = L'\0';
DEBUG ((REDFISH_DEBUG_TRACE, "%a: \"Settings\" found in URI, try: %s\n", __func__, UnicodeUri));
ConfigLang = RedfishGetConfigLanguage (UnicodeUri);
}
}

FreePool (UnicodeUri);

Expand Down Expand Up @@ -2172,6 +2159,65 @@ RedfishSetRedfishUri (
return mConfigLangMapProtocol->Set (mConfigLangMapProtocol, ConfigLang, Uri);
}

/**

Save Redfish SettingsObject URI in database for further use.

@param[in] ParentUri Parent URI of @Redfish.Settings property.
@param[in] SettingObjectUri Redfish SettingsObject Uri to save.

@retval EFI_INVALID_PARAMETER ParentUri or SettingObjectUri is NULL.
@retval EFI_NOT_FOUND Config language for ParentUri is not found.
@retval EFI_SUCCESS Redfish URI is saved with corresponding
config language.

**/
EFI_STATUS
SetRedfishSettingsObjectsUri (
IN EFI_STRING ParentUri,
IN EFI_STRING SettingObjectUri
)
{
EFI_STATUS Status;
EFI_STRING ConfigLang;

if ((ParentUri == NULL) || (SettingObjectUri == NULL)) {
return EFI_INVALID_PARAMETER;
}

//
// Check if the SettingsObject URI already in the database.
//
Status = EFI_SUCCESS;
ConfigLang = RedfishGetConfigLanguage (SettingObjectUri);
if (ConfigLang == NULL) {
//
// No config language of SettingsObject URI is found.
// Get the config language of parent URI because the data model of
// SettingsObject URI resource is the same as the data model of parent URI.
//
ConfigLang = RedfishGetConfigLanguage (ParentUri);
if (ConfigLang == NULL) {
DEBUG ((DEBUG_ERROR, "%a: Failed to get the config language of parent URI that mandates SettingsObject - %s.\n", __func__, ParentUri));
Status = EFI_NOT_FOUND;
} else {
// Set the config language of settings URI using parent's URI config language.
Status = RedfishSetRedfishUri (ConfigLang, SettingObjectUri);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Fails to set the config language of SettingsObject - %s.\n", __func__, SettingObjectUri));
} else {
DEBUG ((DEBUG_INFO, "%a: Set the config language of SettingsObject - %s: SUCCESS.\n", __func__, SettingObjectUri));
}

FreePool (ConfigLang); // Free the ConfigLang of parent URI.
}
} else {
FreePool (ConfigLang); // Free the ConfigLang of SettingObject URI.
}

return Status;
}

/**

Get @odata.id from give HTTP payload. It's call responsibility to release returned buffer.
Expand Down Expand Up @@ -3532,6 +3578,7 @@ CompareRedfishBooleanArrayValues (
payload and URI to pending settings. Caller has to release "SettingPayload" and
"SettingUri".

@param[in] RedfishService Instance of REDFISH_SERVICE
@param[in] Payload Payload that may contain "@Redfish.Settings"
@param[out] SettingPayload Payload keeps pending settings.
@param[out] SettingUri URI to pending settings.
Expand All @@ -3552,6 +3599,7 @@ GetPendingSettings (
EDKII_JSON_VALUE JsonValue;
UINTN Index;
EFI_STATUS Status;
EFI_STRING StrFound;

if ((RedfishService == NULL) || (Payload == NULL) || (SettingResponse == NULL) || (SettingUri == NULL)) {
return EFI_INVALID_PARAMETER;
Expand Down Expand Up @@ -3586,6 +3634,22 @@ GetPendingSettings (
return Status;
}

//
// Setting URI exists, check if settings URI is valid or not.
//
StrFound = StrStr (*SettingUri, L"/Settings");
if (StrFound != NULL) {
DEBUG ((REDFISH_DEBUG_TRACE, "%a: \"Settings\" found in URI: %s\n", __func__, *SettingUri));
} else {
StrFound = StrStr (*SettingUri, L"/SD");
if (StrFound != NULL) {
DEBUG ((REDFISH_DEBUG_TRACE, "%a: \"SD\" found in URI: %s\n", __func__, *SettingUri));
} else {
DEBUG ((DEBUG_ERROR, "%a: Not an valid @redfish.settings URI\n", __func__, *SettingUri));
ASSERT (FALSE);
}
}

return EFI_SUCCESS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

(C) Copyright 2022 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>

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

Expand Down Expand Up @@ -606,10 +607,16 @@ RedfishConfigLangMapSet (
Status = EFI_NOT_FOUND;
Target = FindConfigLangMapRecord (&Private->ConfigLangList.ListHeader, ConfigLang, FALSE);
if (Target != NULL) {
//
// Remove old one and create new one.
//
Status = DeleteConfigLangMapRecord (&Private->ConfigLangList, Target);
if (Uri != NULL) {
if (StrCmp (Uri, Target->Uri) == 0) {
return EFI_SUCCESS;
}
} else {
//
// Remove old one and create new one.
//
Status = DeleteConfigLangMapRecord (&Private->ConfigLangList, Target);
}
}

//
Expand Down
Loading