public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Chang, Abner via groups.io" <abner.chang=amd.com@groups.io>
To: <devel@edk2.groups.io>
Cc: Igor Kulchytskyy <igork@ami.com>, Nickle Wang <nicklew@nvidia.com>
Subject: [edk2-devel] [edk2-redfish-client][PATCH] RedfishClientPkg: Set SettingsObject URI as the config language
Date: Thu, 21 Mar 2024 12:54:21 +0800	[thread overview]
Message-ID: <20240321045421.1087-1-abner.chang@amd.com> (raw)

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

Set SettingsObject URI in @Redfish.Settings resource as the config
language which is the same as the config language of parent URI
that mandates @Redfish.Settings.
With this, we can find the config language of the properties in
SettingsObject URI.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Nickle Wang <nicklew@nvidia.com>
---
 .../RedfishFeatureUtilityLib.c                | 63 +++++++++++++++----
 .../RedfishConfigLangMapDxe.c                 | 15 +++--
 2 files changed, 61 insertions(+), 17 deletions(-)

diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
index cc2b37b796..74bfc611ac 100644
--- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
+++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
@@ -2082,7 +2082,6 @@ GetConfigureLang (
   EFI_STRING  ResultStr;
   EFI_STRING  UnicodeUri;
   EFI_STATUS  Status;
-  EFI_STRING  StrFound;
 
   if (IS_EMPTY_STRING (Uri)) {
     return NULL;
@@ -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);
 
@@ -3532,6 +3519,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.
@@ -3552,6 +3540,9 @@ GetPendingSettings (
   EDKII_JSON_VALUE  JsonValue;
   UINTN             Index;
   EFI_STATUS        Status;
+  EFI_STRING        ConfigLang;
+  EFI_STRING        StrFound;
+  CHAR16            TempChar;
 
   if ((RedfishService == NULL) || (Payload == NULL) || (SettingResponse == NULL) || (SettingUri == NULL)) {
     return EFI_INVALID_PARAMETER;
@@ -3586,6 +3577,52 @@ 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);
+      }
+    }
+
+    //
+    // Check if the SettingsObject URI already in the database.
+    //
+    ConfigLang = RedfishGetConfigLanguage (*SettingUri);
+    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.
+      //
+      TempChar    = StrFound[0];
+      StrFound[0] = L'\0';
+      ConfigLang  = RedfishGetConfigLanguage (*SettingUri);
+      if (ConfigLang == NULL) {
+        DEBUG ((DEBUG_ERROR, "%a: Failed to get the config language of parent URI that mandates SettingsObject - %s.\n", __func__, *SettingUri));
+        return EFI_NOT_FOUND;
+      }
+
+      StrFound[0] = TempChar;
+
+      // Set the config language of settings URI using parent's URI config language.
+      Status = RedfishSetRedfishUri (ConfigLang, *SettingUri);
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_ERROR, "%a: Fails to set the config language of SettingsObject - %s.\n", __func__, *SettingUri));
+        return Status;
+      }
+
+      DEBUG ((DEBUG_INFO, "%a: Set the config language of SettingsObject - %s: SUCCESS.\n", __func__, *SettingUri));
+    }
+
     return EFI_SUCCESS;
   }
 
diff --git a/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.c b/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.c
index 8c93044580..4071e30c17 100644
--- a/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.c
+++ b/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.c
@@ -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
 
@@ -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);
+    }
   }
 
   //
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116946): https://edk2.groups.io/g/devel/message/116946
Mute This Topic: https://groups.io/mt/105059880/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



                 reply	other threads:[~2024-03-21  4:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240321045421.1087-1-abner.chang@amd.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