From: "Igor Kulchytskyy via groups.io" <igork=ami.com@groups.io>
To: "abner.chang@amd.com" <abner.chang@amd.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Nickle Wang <nicklew@nvidia.com>
Subject: Re: [edk2-devel] [PATCH V3 2/6] RedfishPkg/RedfishDebugLib: Introduce Redfish DEBUG macro
Date: Thu, 4 Apr 2024 13:33:34 +0000 [thread overview]
Message-ID: <BLAPR10MB51858D4037E30322EC5E4245A83C2@BLAPR10MB5185.namprd10.prod.outlook.com> (raw)
In-Reply-To: <20240404101758.84-3-abner.chang@amd.com>
Reviewed-by: Igor Kulchytskyy <igork@ami.com>
Regards,
Igor
-----Original Message-----
From: abner.chang@amd.com <abner.chang@amd.com>
Sent: Thursday, April 4, 2024 6:18 AM
To: devel@edk2.groups.io
Cc: Nickle Wang <nicklew@nvidia.com>; Igor Kulchytskyy <igork@ami.com>
Subject: [EXTERNAL] [PATCH V3 2/6] RedfishPkg/RedfishDebugLib: Introduce Redfish DEBUG macro
**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**
From: Abner Chang <abner.chang@amd.com>
Introduce DEBUG_REDFISH macro for the debug message
of edk2 Redfish components.
DEBUG_REDFISH can be used in any edk2 Redfish component
with Redfish DebugCatagory as the first parameter.
Whether the debug message is output or not depends on
the platform setting of PcdRedfishDebugCatagory.
Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Nickle Wang <nicklew@nvidia.com>
---
RedfishPkg/RedfishPkg.dec | 9 +++
.../RedfishDebugLib/RedfishDebugLib.inf | 4 ++
RedfishPkg/Include/Library/RedfishDebugLib.h | 43 +++++++++++----
.../Library/RedfishDebugLib/RedfishDebugLib.c | 55 ++++---------------
4 files changed, 57 insertions(+), 54 deletions(-)
diff --git a/RedfishPkg/RedfishPkg.dec b/RedfishPkg/RedfishPkg.dec
index 1a9c9ed7bc5..a9665ff68ef 100644
--- a/RedfishPkg/RedfishPkg.dec
+++ b/RedfishPkg/RedfishPkg.dec
@@ -5,6 +5,7 @@
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
# Copyright (c) 2023, American Megatrends International LLC.
# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
@@ -184,3 +185,11 @@
gEfiRedfishPkgTokenSpaceGuid.PcdHttpRetryWaitInSecond|1|UINT16|0x00001010
## This is used to disable Redfish HTTP cache function and every request will be sent to Redfish service.
gEfiRedfishPkgTokenSpaceGuid.PcdHttpCacheDisabled|FALSE|BOOLEAN|0x00001011
+ #
+ # Redfish debug catagories
+ # To enable the debug message for the entire edk2 Redfish implementation, below PCDs must be set.
+ # DEBUG_MANAGEABILITY must be set PcdDebugPrintErrorLevel.
+ #
+ # 0x0000000000000001 RedfishPlatformConfigDxe driver debug enabled.
+ #
+ gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDebugCategory|0|UINT64|0x00001012
diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf
index d468bb213b6..42ff321b48e 100644
--- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf
+++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf
@@ -2,6 +2,7 @@
# INF file for Redfish debug library.
#
# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -35,5 +36,8 @@
RedfishHttpLib
UefiLib
+[FixedPcd]
+ gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDebugCategory
+
[Depex]
TRUE
diff --git a/RedfishPkg/Include/Library/RedfishDebugLib.h b/RedfishPkg/Include/Library/RedfishDebugLib.h
index ad7a6975867..19e5a895cc8 100644
--- a/RedfishPkg/Include/Library/RedfishDebugLib.h
+++ b/RedfishPkg/Include/Library/RedfishDebugLib.h
@@ -2,6 +2,7 @@
This file defines the Redfish debug library interface.
Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -11,28 +12,48 @@
#define REDFISH_DEBUG_LIB_H_
#include <Uefi.h>
+#include <Library/DebugLib.h>
#include <RedfishServiceData.h>
#include <Library/HiiUtilityLib.h>
#include <Library/JsonLib.h>
#include <Protocol/EdkIIRedfishPlatformConfig.h>
-#define DEBUG_REDFISH_NETWORK DEBUG_MANAGEABILITY ///< Debug error level for Redfish networking function
-#define DEBUG_REDFISH_HOST_INTERFACE DEBUG_MANAGEABILITY ///< Debug error level for Redfish networking function
+// Used with MdePKg DEBUG macro.
+#define DEBUG_REDFISH_NETWORK DEBUG_MANAGEABILITY ///< Debug error level for Redfish networking function
+#define DEBUG_REDFISH_HOST_INTERFACE DEBUG_MANAGEABILITY ///< Debug error level for Redfish Host INterface
+#define DEBUG_REDFISH_PLATFORM_CONFIG DEBUG_MANAGEABILITY ///< Debug error level for Redfish Platform Configure Driver
+
+//
+// Definitions of Redfish debug capability in Redfish component scope, used with DEBUG_REDFISH macro
+// For example, Redfish Platform Config Driver
+// DEBUG_REDFISH(DEBUG_REDFISH_PLATFORM_CONFIG_DXE, ...)
+//
+#define DEBUG_REDFISH_COMPONENT_PLATFORM_CONFIG_DXE 0x00000001
+
+#define DEBUG_REDFISH(DebugCategory, ...) \
+ do { \
+ if (!DebugPrintEnabled()) { \
+ break; \
+ } \
+ if (!DebugRedfishComponentEnabled (DebugCategory)) { \
+ break; \
+ } \
+ DEBUG ((DEBUG_MANAGEABILITY, ##__VA_ARGS__)); \
+ } while (FALSE)
/**
- Debug print the value of StatementValue.
+ Determine whether the Redfish debug category is enabled in
+ gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDebugCategory.
- @param[in] ErrorLevel DEBUG macro error level.
- @param[in] StatementValue The statement value to print.
+ @param[in] DebugCategory Redfish debug category.
- @retval EFI_SUCCESS StatementValue is printed.
- @retval EFI_INVALID_PARAMETER StatementValue is NULL.
+ @retval TRUE This debug category is enabled.
+ @retval FALSE This debug category is disabled..
**/
-EFI_STATUS
-DumpHiiStatementValue (
- IN UINTN ErrorLevel,
- IN HII_STATEMENT_VALUE *StatementValue
+BOOLEAN
+DebugRedfishComponentEnabled (
+ IN UINT64 DebugCategory
);
/**
diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
index 8b0425b8c3b..f8bb51ff532 100644
--- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
+++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
@@ -2,6 +2,7 @@
Redfish debug library to debug Redfish application.
Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -25,55 +26,23 @@
#define REDFISH_PRINT_BUFFER_BYTES_PER_ROW 16
/**
- Debug print the value of StatementValue.
+ Determine whether the Redfish debug category is enabled in
+ gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDebugCategory.
- @param[in] ErrorLevel DEBUG macro error level.
- @param[in] StatementValue The statement value to print.
+ @param[in] RedfishDebugCategory Redfish debug category.
- @retval EFI_SUCCESS StatementValue is printed.
- @retval EFI_INVALID_PARAMETER StatementValue is NULL.
+ @retval TRUE This debug category is enabled.
+ @retval FALSE This debug category is disabled..
**/
-EFI_STATUS
-DumpHiiStatementValue (
- IN UINTN ErrorLevel,
- IN HII_STATEMENT_VALUE *StatementValue
+BOOLEAN
+DebugRedfishComponentEnabled (
+ IN UINT64 RedfishDebugCategory
)
{
- if (StatementValue == NULL) {
- return EFI_INVALID_PARAMETER;
- }
+ UINT64 DebugCategory;
- DEBUG ((ErrorLevel, "BufferValueType: 0x%x\n", StatementValue->BufferValueType));
- DEBUG ((ErrorLevel, "BufferLen: 0x%x\n", StatementValue->BufferLen));
- DEBUG ((ErrorLevel, "Buffer: 0x%p\n", StatementValue->Buffer));
- DEBUG ((ErrorLevel, "Type: 0x%p\n", StatementValue->Type));
-
- switch (StatementValue->Type) {
- case EFI_IFR_TYPE_NUM_SIZE_8:
- DEBUG ((ErrorLevel, "Value: 0x%x\n", StatementValue->Value.u8));
- break;
- case EFI_IFR_TYPE_NUM_SIZE_16:
- DEBUG ((ErrorLevel, "Value: 0x%x\n", StatementValue->Value.u16));
- break;
- case EFI_IFR_TYPE_NUM_SIZE_32:
- DEBUG ((ErrorLevel, "Value: 0x%x\n", StatementValue->Value.u32));
- break;
- case EFI_IFR_TYPE_NUM_SIZE_64:
- DEBUG ((ErrorLevel, "Value: 0x%lx\n", StatementValue->Value.u64));
- break;
- case EFI_IFR_TYPE_BOOLEAN:
- DEBUG ((ErrorLevel, "Value: %a\n", (StatementValue->Value.b ? "true" : "false")));
- break;
- case EFI_IFR_TYPE_STRING:
- DEBUG ((ErrorLevel, "Value: 0x%x\n", StatementValue->Value.string));
- break;
- case EFI_IFR_TYPE_TIME:
- case EFI_IFR_TYPE_DATE:
- default:
- break;
- }
-
- return EFI_SUCCESS;
+ DebugCategory = FixedPcdGet64 (PcdRedfishDebugCategory);
+ return ((DebugCategory & RedfishDebugCategory) != 0);
}
/**
--
2.37.1.windows.1
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117430): https://edk2.groups.io/g/devel/message/117430
Mute This Topic: https://groups.io/mt/105326103/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-04-04 13:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-04 10:17 [edk2-devel] [PATCH V3 0/6] Config language searching algorithm enhancement and the bug fixes Chang, Abner via groups.io
2024-04-04 10:17 ` [edk2-devel] [PATCH V3 1/6] RedfishPkg/RedfishPlatformConfigDxe: Config language searching optimization Chang, Abner via groups.io
2024-04-04 13:34 ` Igor Kulchytskyy via groups.io
2024-04-04 10:17 ` [edk2-devel] [PATCH V3 2/6] RedfishPkg/RedfishDebugLib: Introduce Redfish DEBUG macro Chang, Abner via groups.io
2024-04-04 13:33 ` Igor Kulchytskyy via groups.io [this message]
2024-04-04 10:17 ` [edk2-devel] [PATCH V3 3/6] RedfishPkg/RedfishPlatformConfigDxe:Add RefishDebugLib support Chang, Abner via groups.io
2024-04-04 13:33 ` Igor Kulchytskyy via groups.io
2024-04-04 10:17 ` [edk2-devel] [PATCH V3 4/6] RedfishPkg/RedfishPlatformConfigDxe: HII string is deleted unexpectedly Chang, Abner via groups.io
2024-04-04 13:34 ` Igor Kulchytskyy via groups.io
2024-04-04 10:17 ` [edk2-devel] [PATCH V3 5/6] EmulatorPkg/Redfish: Use edk2 Redfish debug PCDs Chang, Abner via groups.io
2024-04-04 10:17 ` [edk2-devel] [PATCH V3 6/6] RedfishPkg/RedfishPlatformConfigDxe: support menu path report Chang, Abner via groups.io
2024-04-04 13:34 ` Igor Kulchytskyy via groups.io
2024-04-04 13:33 ` [edk2-devel] [PATCH V3 0/6] Config language searching algorithm enhancement and the bug fixes Igor Kulchytskyy via groups.io
2024-04-04 14:26 ` Chang, Abner via groups.io
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=BLAPR10MB51858D4037E30322EC5E4245A83C2@BLAPR10MB5185.namprd10.prod.outlook.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