public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Nickle Wang via groups.io" <nicklew=nvidia.com@groups.io>
To: <devel@edk2.groups.io>
Cc: Abner Chang <abner.chang@amd.com>,
	Igor Kulchytskyy <igork@ami.com>,
	"Nick Ramirez" <nramirez@nvidia.com>
Subject: [edk2-devel] [edk2-redfish-client][PATCH 10/10] RedfishClientPkg/RedfishFeatureUtilityLib: use HTTP cache lib
Date: Wed, 3 Jan 2024 20:01:19 +0800	[thread overview]
Message-ID: <20240103120119.62406-1-nicklew@nvidia.com> (raw)

Use Redfish Http cache library to query Redfish service.

Signed-off-by: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Nick Ramirez <nramirez@nvidia.com>
---
 .../RedfishFeatureUtilityLib.inf              |  3 +-
 .../Library/RedfishFeatureUtilityLib.h        | 21 +-----
 .../RedfishFeatureUtilityInternal.h           |  3 +-
 .../RedfishFeatureUtilityLib.c                | 67 ++-----------------
 4 files changed, 9 insertions(+), 85 deletions(-)

diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf
index fd66b8ac..718273b2 100644
--- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf
+++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf
@@ -2,7 +2,7 @@
 #  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.
+#  Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -46,6 +46,7 @@
   PrintLib
   HttpLib
   RedfishDebugLib
+  RedfishHttpCacheLib
 
 [Protocols]
   gEdkIIRedfishETagProtocolGuid           ## CONSUMED ##
diff --git a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
index 24f0ad24..9513a656 100644
--- a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
+++ b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
@@ -2,7 +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.
+  Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -18,25 +18,6 @@
 
 #define REDFISH_ENABLE_SYSTEM_REBOOT()  PcdSetBoolS(PcdRedfishSystemRebootRequired, TRUE)
 
-/**
-
-  Read redfish resource by given resource URI.
-
-  @param[in]  Service       Redfish service instance to make query.
-  @param[in]  ResourceUri   Target resource URI.
-  @param[out] Response      HTTP response from redfish service.
-
-  @retval     EFI_SUCCESS     Resrouce is returned successfully.
-  @retval     Others          Errors occur.
-
-**/
-EFI_STATUS
-GetResourceByUri (
-  IN  REDFISH_SERVICE   *Service,
-  IN  EFI_STRING        ResourceUri,
-  OUT REDFISH_RESPONSE  *Response
-  );
-
 /**
 
   Check if this is the Redpath array. Usually the Redpath array represents
diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityInternal.h b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityInternal.h
index 5d39984c..b4cfca03 100644
--- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityInternal.h
+++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityInternal.h
@@ -2,7 +2,7 @@
   Common header file for RedfishFeatureUtilityLib driver.
 
   (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
-  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -30,6 +30,7 @@
 #include <Library/PrintLib.h>
 #include <Library/HttpLib.h>
 #include <Library/RedfishDebugLib.h>
+#include <Library/RedfishHttpCacheLib.h>
 
 #include <Guid/VariableFormat.h>
 
diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
index 01c054ae..34868a13 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) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -147,7 +147,8 @@ SetEtagFromUri (
     return Status;
   }
 
-  Status = GetResourceByUri (RedfishService, Uri, &Response);
+  ZeroMem (&Response, sizeof (Response));
+  Status = RedfishHttpGetResource (RedfishService, Uri, &Response, TRUE);
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
     return Status;
@@ -1163,66 +1164,6 @@ ApplyFeatureSettingsBooleanArrayType (
   return Status;
 }
 
-/**
-
-  Read redfish resource by given resource URI.
-
-  @param[in]  Service       Redfish service instance to make query.
-  @param[in]  ResourceUri   Target resource URI.
-  @param[out] Response      HTTP response from redfish service.
-
-  @retval     EFI_SUCCESS     Resrouce is returned successfully.
-  @retval     Others          Errors occur.
-
-**/
-EFI_STATUS
-GetResourceByUri (
-  IN  REDFISH_SERVICE   *Service,
-  IN  EFI_STRING        ResourceUri,
-  OUT REDFISH_RESPONSE  *Response
-  )
-{
-  EFI_STATUS  Status;
-  CHAR8       *AsciiResourceUri;
-
-  if ((Service == NULL) || (Response == NULL) || IS_EMPTY_STRING (ResourceUri)) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  AsciiResourceUri = StrUnicodeToAscii (ResourceUri);
-  if (AsciiResourceUri == NULL) {
-    return EFI_OUT_OF_RESOURCES;
-  }
-
-  //
-  // Get resource from redfish service.
-  //
-  Status = RedfishGetByUri (
-             Service,
-             AsciiResourceUri,
-             Response
-             );
-  if (EFI_ERROR (Status)) {
-    DEBUG ((DEBUG_ERROR, "%a: RedfishGetByUri to %a failed: %r\n", __func__, AsciiResourceUri, Status));
-    if (Response->Payload != NULL) {
-      RedfishDumpPayload (Response->Payload);
-      RedfishFreeResponse (
-        NULL,
-        0,
-        NULL,
-        Response->Payload
-        );
-      Response->Payload = NULL;
-    }
-  }
-
-  if (AsciiResourceUri != NULL) {
-    FreePool (AsciiResourceUri);
-  }
-
-  return Status;
-}
-
 /**
 
   Check if this is the Redpath array. Usually the Redpath array represents
@@ -3704,7 +3645,7 @@ GetPendingSettings (
       return EFI_NOT_FOUND;
     }
 
-    Status = GetResourceByUri (RedfishService, *SettingUri, SettingResponse);
+    Status = RedfishHttpGetResource (RedfishService, *SettingUri, SettingResponse, TRUE);
     if (EFI_ERROR (Status)) {
       DEBUG ((DEBUG_ERROR, "%a: @Redfish.Settings exists, get resource from: %s failed: %r\n", __func__, *SettingUri, Status));
       return Status;
-- 
2.34.1



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



                 reply	other threads:[~2024-01-03 12:01 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=20240103120119.62406-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