Skip to content

Commit

Permalink
RedfishPkg/RedfishPlatformConfigDxe:Add RefishDebugLib support
Browse files Browse the repository at this point in the history
Add RedfishPlatformConfigDxe debug capability that aligns
with edk2 Redfish debug mechanism.

- PcdRedfishPlatformConfigDebugProperty, add PCD to control
  RedfishPlatformConfigDxe subordinate of Redfish debug
  capabilities.
- PcdRedfishPlatformConfigFeatureProperty, add PCD to
  manage RedfishPlatformConfigDxe features.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Co-authored-by: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Nickle Wang <nicklew@nvidia.com>
Reviewed-by: Igor Kulchytskyy <igork@ami.com>
  • Loading branch information
2 people authored and mergify[bot] committed Apr 4, 2024
1 parent b0be425 commit c8f5680
Show file tree
Hide file tree
Showing 7 changed files with 262 additions and 59 deletions.
15 changes: 15 additions & 0 deletions RedfishPkg/RedfishPkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,18 @@
# 0x0000000000000001 RedfishPlatformConfigDxe driver debug enabled.
#
gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDebugCategory|0|UINT64|0x00001012
#
# Redfish RedfishPlatformConfigDxe Debug Properties
# 0x00000001 x-uefi-redfish string database message enabled
# 0x00000002 Debug Message for dumping formset
# 0x00000004 Debug Message for x-uefi-redfish searching result
# 0x00000008 Debug Message for x-uefi-redfish Regular Expression searching result
#
gEfiRedfishPkgTokenSpaceGuid.PcdRedfishPlatformConfigDebugProperty|0|UINT32|0x00001013
#
# RedfishPlatformConfigDxe feature enablement
# 0x00000001 Enable building Redfish Attribute Registry menu path.
# 0x00000002 Allow supressed HII option to be exposed on Redfish.
#
# Redfish RedfishPlatformConfigDxe feature Properties
gEfiRedfishPkgTokenSpaceGuid.PcdRedfishPlatformConfigFeatureProperty|0|UINT32|0x00001014
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/** @file
The implementation of EDKII Redfish Platform Config Capability.
Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#include "RedfishPlatformConfigDxe.h"
#include "RedfishPlatformConfigImpl.h"

/**
Check if the debug property is enabled or not.
@param[in] DebugType Debug enablement type
@retval TRUE, the debug property is enabled.
FALSE, the debug property is not enabled.
**/
BOOLEAN
RedfishPlatformConfigDebugProp (
IN UINT64 DebugType
)
{
UINT64 DebugProp;

DebugProp = FixedPcdGet64 (PcdRedfishPlatformConfigDebugProperty);
if ((DebugProp & DebugType) != 0) {
return TRUE;
}

return FALSE;
}

/**
Check if the Platform Configure feature is enabled or not.
@param[in] FeatureType Redfish platform config feature enablement
@retval TRUE, the feature is enabled.
FALSE, the feature is not enabled.
**/
BOOLEAN
RedfishPlatformConfigFeatureProp (
IN UINT64 FeatureType
)
{
UINT64 FeatureProp;

FeatureProp = FixedPcdGet64 (PcdRedfishPlatformConfigFeatureProperty);
if ((FeatureProp & FeatureType) != 0) {
return TRUE;
}

return FALSE;
}
59 changes: 41 additions & 18 deletions RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ DumpHiiStatementPrompt (
**/
CHAR8 *
BuildMenPath (
BuildMenuPath (
IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *StatementPrivate
)
{
Expand Down Expand Up @@ -345,7 +345,7 @@ BuildMenPath (
}

do {
DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "F(%d) <-", FormPrivate->Id));
DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "F(%d) <-", FormPrivate->Id));
FormPrivate = FindFormLinkToThis (FormPrivate);
if (FormPrivate == NULL) {
break;
Expand Down Expand Up @@ -387,7 +387,7 @@ BuildMenPath (
AsciiStrCatS (Buffer, OldBufferSize, "/");
AsciiStrCatS (Buffer, OldBufferSize, FormTitle);
FreePool (FormTitle);
DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, " %a\n", Buffer));
DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, " %a\n", Buffer));
}

FormPrivate = (REDFISH_PLATFORM_CONFIG_FORM_PRIVATE *)PopRedfishStack (FormStack);
Expand Down Expand Up @@ -1061,12 +1061,12 @@ DumpOrderedListValue (
return;
}

DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "Value.Type= 0x%x\n", OrderedListStatement->Value.Type));
DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "Value.BufferValueType= 0x%x\n", OrderedListStatement->Value.BufferValueType));
DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "Value.BufferLen= 0x%x\n", OrderedListStatement->Value.BufferLen));
DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "Value.Buffer= 0x%x\n", OrderedListStatement->Value.Buffer));
DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "Value.MaxContainers= 0x%x\n", OrderedListStatement->ExtraData.OrderListData.MaxContainers));
DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "StorageWidth= 0x%x\n", OrderedListStatement->StorageWidth));
DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "Value.Type= 0x%x\n", OrderedListStatement->Value.Type));
DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "Value.BufferValueType= 0x%x\n", OrderedListStatement->Value.BufferValueType));
DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "Value.BufferLen= 0x%x\n", OrderedListStatement->Value.BufferLen));
DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "Value.Buffer= 0x%x\n", OrderedListStatement->Value.Buffer));
DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "Value.MaxContainers= 0x%x\n", OrderedListStatement->ExtraData.OrderListData.MaxContainers));
DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "StorageWidth= 0x%x\n", OrderedListStatement->StorageWidth));

if (OrderedListStatement->Value.Buffer == NULL) {
return;
Expand All @@ -1083,45 +1083,45 @@ DumpOrderedListValue (
Value8 = (UINT8 *)OrderedListStatement->Value.Buffer;
Count = OrderedListStatement->StorageWidth / sizeof (UINT8);
for (Index = 0; Index < Count; Index++) {
DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "%d ", Value8[Index]));
DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%d ", Value8[Index]));
}

break;
case EFI_IFR_TYPE_NUM_SIZE_16:
Value16 = (UINT16 *)OrderedListStatement->Value.Buffer;
Count = OrderedListStatement->StorageWidth / sizeof (UINT16);
for (Index = 0; Index < Count; Index++) {
DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "%d ", Value16[Index]));
DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%d ", Value16[Index]));
}

break;
case EFI_IFR_TYPE_NUM_SIZE_32:
Value32 = (UINT32 *)OrderedListStatement->Value.Buffer;
Count = OrderedListStatement->StorageWidth / sizeof (UINT32);
for (Index = 0; Index < Count; Index++) {
DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "%d ", Value32[Index]));
DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%d ", Value32[Index]));
}

break;
case EFI_IFR_TYPE_NUM_SIZE_64:
Value64 = (UINT64 *)OrderedListStatement->Value.Buffer;
Count = OrderedListStatement->StorageWidth / sizeof (UINT64);
for (Index = 0; Index < Count; Index++) {
DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "%d ", Value64[Index]));
DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%d ", Value64[Index]));
}

break;
default:
Value8 = (UINT8 *)OrderedListStatement->Value.Buffer;
Count = OrderedListStatement->StorageWidth / sizeof (UINT8);
for (Index = 0; Index < Count; Index++) {
DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "%d ", Value8[Index]));
DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%d ", Value8[Index]));
}

break;
}

DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "\n"));
DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "\n"));
}

/**
Expand Down Expand Up @@ -2013,6 +2013,8 @@ RedfishPlatformConfigProtocolGetConfigureLang (
UINTN Index;
CHAR8 *FullSchema;

DEBUG ((DEBUG_INFO, "%a: Harvest config language of %a_%a (Regex: %s).\n", __func__, Schema, Version, RegexPattern));

if ((This == NULL) || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || (Count == NULL) || (ConfigureLangList == NULL) || IS_EMPTY_STRING (RegexPattern)) {
return EFI_INVALID_PARAMETER;
}
Expand Down Expand Up @@ -2072,6 +2074,22 @@ RedfishPlatformConfigProtocolGetConfigureLang (
*Count = StatementList.Count;
*ConfigureLangList = TmpConfigureLangList;

DEBUG_REDFISH_THIS_MODULE (
REDFISH_PLATFORM_CONFIG_DEBUG_CONFIG_LANG_REGEX,
"%a: Number of configure language strings harvested: %d\n",
__func__,
StatementList.Count
);

DEBUG_REDFISH_THIS_MODULE_CODE (
REDFISH_PLATFORM_CONFIG_DEBUG_CONFIG_LANG_REGEX,
DEBUG_REDFISH (DEBUG_REDFISH_COMPONENT_PLATFORM_CONFIG_DXE, "%a: Number of configure language strings harvested: %d\n", __func__, StatementList.Count);
for (Index = 0; Index < *Count; Index++) {
DEBUG_REDFISH (DEBUG_REDFISH_COMPONENT_PLATFORM_CONFIG_DXE, " (%d) %s\n", Index, TmpConfigureLangList[Index]);
}

);

RELEASE_RESOURCE:

if (FullSchema != NULL) {
Expand All @@ -2082,6 +2100,7 @@ RedfishPlatformConfigProtocolGetConfigureLang (
ReleaseStatementList (&StatementList);
}

DEBUG ((DEBUG_INFO, "%a: exit.\n", __func__));
return Status;
}

Expand Down Expand Up @@ -2296,6 +2315,7 @@ RedfishPlatformConfigProtocolGetAttribute (
CHAR8 *FullSchema;
CHAR8 *Buffer;

DEBUG ((DEBUG_INFO, "%a: Entry\n", __func__));
if ((This == NULL) || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_STRING (ConfigureLang) || (AttributeValue == NULL)) {
return EFI_INVALID_PARAMETER;
}
Expand Down Expand Up @@ -2337,9 +2357,11 @@ RedfishPlatformConfigProtocolGetAttribute (
//
// Build up menu path
//
AttributeValue->MenuPath = BuildMenPath (TargetStatement);
if (AttributeValue->MenuPath == NULL) {
DEBUG ((DEBUG_ERROR, "%a: failed to build menu path for \"%a\"\n", __func__, AttributeValue->AttributeName));
if (RedfishPlatformConfigFeatureProp (REDFISH_PLATFORM_CONFIG_BUILD_MENU_PATH)) {
AttributeValue->MenuPath = BuildMenuPath (TargetStatement);
if (AttributeValue->MenuPath == NULL) {
DEBUG ((DEBUG_ERROR, "%a: failed to build menu path for \"%a\"\n", __func__, AttributeValue->AttributeName));
}
}

//
Expand Down Expand Up @@ -2370,6 +2392,7 @@ RedfishPlatformConfigProtocolGetAttribute (
FreePool (FullSchema);
}

DEBUG ((DEBUG_INFO, "%a: Exit\n", __func__));
return Status;
}

Expand Down
46 changes: 44 additions & 2 deletions RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
(C) Copyright 2021 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 All @@ -20,7 +21,9 @@
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/PrintLib.h>
#include <Library/RedfishDebugLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
Expand All @@ -37,6 +40,41 @@
//
#include <Protocol/EdkIIRedfishPlatformConfig.h>

//
// Debug message in DEBUG_REDFISH_COMPONENT_PLATFORM_CONFIG_DXE scope.
// To enable the debug message for this module, below PCDs must be set.
//
// 1. DEBUG_MANAGEABILITY must be set PcdDebugPrintErrorLevel.
//
// 2 RedfishPlatformConfigDxe debug enablement must be set in
// PcdRedfishDebugCategory (defined in RedfishPkg.dec)
//
// 3. The suborinate debug enablement for RedfishPlatformConfigDxe
// must be set in PcdRedfishPlatformConfigDebugPropert (defined
// in RedfishPkg.dec).
//
#define DEBUG_REDFISH_THIS_MODULE(DebugSubordinate, ...) \
while (RedfishPlatformConfigDebugProp (DebugSubordinate)) { \
DEBUG_REDFISH(DEBUG_REDFISH_COMPONENT_PLATFORM_CONFIG_DXE, ##__VA_ARGS__); \
break; \
}

#define DEBUG_REDFISH_THIS_MODULE_CODE_BEGIN(DebugSubordinate) \
if (RedfishPlatformConfigDebugProp (DebugSubordinate)) {

#define DEBUG_REDFISH_THIS_MODULE_CODE_END() }

#define DEBUG_REDFISH_THIS_MODULE_CODE(DebugSubordinate, Expression) \
DEBUG_REDFISH_THIS_MODULE_CODE_BEGIN(DebugSubordinate) \
Expression \
DEBUG_REDFISH_THIS_MODULE_CODE_END()

// Subordinate debug property for DEBUG_REDFISH_PLATFORM_CONFIG_DXE
#define REDFISH_PLATFORM_CONFIG_DEBUG_STRING_DATABASE 0x00000001
#define REDFISH_PLATFORM_CONFIG_DEBUG_DUMP_FORMSET 0x00000002
#define REDFISH_PLATFORM_CONFIG_DEBUG_CONFIG_LANG_SEARCH 0x00000004
#define REDFISH_PLATFORM_CONFIG_DEBUG_CONFIG_LANG_REGEX 0x00000008

///
/// Definition of EDKII_REDFISH_PLATFORM_CONFIG_NOTIFY.
///
Expand Down Expand Up @@ -75,8 +113,12 @@ typedef struct {
#define REGULAR_EXPRESSION_INCLUDE_ALL L".*"
#define CONFIGURE_LANGUAGE_PREFIX "x-uefi-redfish-"
#define REDFISH_PLATFORM_CONFIG_VERSION 0x00010000
#define REDFISH_PLATFORM_CONFIG_DEBUG DEBUG_MANAGEABILITY
#define REDFISH_MENU_PATH_SIZE 8

#define REDFISH_MENU_PATH_SIZE 8

// Definitions of Redfish platform config capbility
#define REDFISH_PLATFORM_CONFIG_BUILD_MENU_PATH 0x000000001
#define REDFISH_PLATFORM_CONFIG_ALLOW_SUPPRESSED 0x000000002

/**
Convert input unicode string to ascii string. It's caller's
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
# Copyright (c) 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 All @@ -23,6 +24,7 @@
RedfishPkg/RedfishPkg.dec

[Sources]
RedfishPlatformConfigCapability.c
RedfishPlatformConfigDxe.h
RedfishPlatformConfigDxe.c
RedfishPlatformConfigImpl.h
Expand All @@ -36,7 +38,9 @@
HiiLib
HiiUtilityLib
MemoryAllocationLib
PcdLib
PrintLib
RedfishDebugLib
UefiLib
UefiBootServicesTableLib
UefiRuntimeServicesTableLib
Expand All @@ -51,5 +55,9 @@
[Guids]
gEfiRegexSyntaxTypePerlGuid ## CONSUMED

[FixedPcd]
gEfiRedfishPkgTokenSpaceGuid.PcdRedfishPlatformConfigFeatureProperty
gEfiRedfishPkgTokenSpaceGuid.PcdRedfishPlatformConfigDebugProperty

[Depex]
TRUE
Loading

0 comments on commit c8f5680

Please sign in to comment.