public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH] RedfishPkg/RedfishDebugLib: add function to print buffer.
@ 2024-01-09  7:14 Nickle Wang via groups.io
  2024-01-09  7:59 ` Chang, Abner via groups.io
  0 siblings, 1 reply; 3+ messages in thread
From: Nickle Wang via groups.io @ 2024-01-09  7:14 UTC (permalink / raw)
  To: devel; +Cc: Abner Chang, Igor Kulchytskyy, Nick Ramirez

Introduce DumpBuffer function to print the buffer content. This helps
developer to debug Redfish issue.

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>
---
 RedfishPkg/Include/Library/RedfishDebugLib.h  | 20 ++++++++-
 .../Library/RedfishDebugLib/RedfishDebugLib.c | 41 ++++++++++++++++++-
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/RedfishPkg/Include/Library/RedfishDebugLib.h b/RedfishPkg/Include/Library/RedfishDebugLib.h
index 5f75bad12a..3430cf1d14 100644
--- a/RedfishPkg/Include/Library/RedfishDebugLib.h
+++ b/RedfishPkg/Include/Library/RedfishDebugLib.h
@@ -1,7 +1,7 @@
 /** @file
   This file defines the Redfish debug library interface.
 
-  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
 
@@ -138,4 +138,22 @@ DumpIpv4Address (
   IN EFI_IPv4_ADDRESS  *Ipv4Address
   );
 
+/**
+  Debug output raw data buffer.
+
+  @param[in]    ErrorLevel  DEBUG macro error level
+  @param[in]    Buffer      Debug output data buffer.
+  @param[in]    BufferSize  The size of Buffer in byte.
+
+  @retval EFI_SUCCESS             Debug dump finished.
+  @retval EFI_INVALID_PARAMETER   Buffer is NULL.
+
+**/
+EFI_STATUS
+DumpBuffer (
+  IN  UINTN  ErrorLevel,
+  IN  UINT8  *Buffer,
+  IN  UINTN  BufferSize
+  );
+
 #endif
diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
index efa9a5ca13..5fd40ad955 100644
--- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
+++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
@@ -1,7 +1,7 @@
 /** @file
   Redfish debug library to debug Redfish application.
 
-  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
 
@@ -21,6 +21,7 @@
 
 #define REDFISH_JSON_STRING_LENGTH  200
 #define REDFISH_JSON_OUTPUT_FORMAT  (EDKII_JSON_COMPACT | EDKII_JSON_INDENT(2))
+#define REDFISH_SIZE_PER_ROW        16
 
 /**
   Debug print the value of StatementValue.
@@ -366,3 +367,41 @@ DumpIpv4Address (
 
   return EFI_SUCCESS;
 }
+
+/**
+  Debug output raw data buffer.
+
+  @param[in]    ErrorLevel  DEBUG macro error level
+  @param[in]    Buffer      Debug output data buffer.
+  @param[in]    BufferSize  The size of Buffer in byte.
+
+  @retval EFI_SUCCESS             Debug dump finished.
+  @retval EFI_INVALID_PARAMETER   Buffer is NULL.
+
+**/
+EFI_STATUS
+DumpBuffer (
+  IN  UINTN  ErrorLevel,
+  IN  UINT8  *Buffer,
+  IN  UINTN  BufferSize
+  )
+{
+  UINTN  Index;
+
+  if (Buffer == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  DEBUG ((ErrorLevel, "Address: 0x%p size: %d\n", Buffer, BufferSize));
+  for (Index = 0; Index < BufferSize; Index++) {
+    if (Index % REDFISH_SIZE_PER_ROW == 0) {
+      DEBUG ((ErrorLevel, "\n%04X: ", Index));
+    }
+
+    DEBUG ((ErrorLevel, "%02X ", Buffer[Index]));
+  }
+
+  DEBUG ((ErrorLevel, "\n"));
+
+  return EFI_SUCCESS;
+}
-- 
2.34.1



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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [PATCH] RedfishPkg/RedfishDebugLib: add function to print buffer.
  2024-01-09  7:14 [edk2-devel] [PATCH] RedfishPkg/RedfishDebugLib: add function to print buffer Nickle Wang via groups.io
@ 2024-01-09  7:59 ` Chang, Abner via groups.io
  2024-01-09 11:14   ` Nickle Wang via groups.io
  0 siblings, 1 reply; 3+ messages in thread
From: Chang, Abner via groups.io @ 2024-01-09  7:59 UTC (permalink / raw)
  To: Nickle Wang, devel@edk2.groups.io; +Cc: Igor Kulchytskyy, Nick Ramirez

[AMD Official Use Only - General]

> -----Original Message-----
> From: Nickle Wang <nicklew@nvidia.com>
> Sent: Tuesday, January 9, 2024 3:15 PM
> To: devel@edk2.groups.io
> Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy
> <igork@ami.com>; Nick Ramirez <nramirez@nvidia.com>
> Subject: [PATCH] RedfishPkg/RedfishDebugLib: add function to print buffer.
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Introduce DumpBuffer function to print the buffer content. This helps
> developer to debug Redfish issue.
>
> 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>
> ---
>  RedfishPkg/Include/Library/RedfishDebugLib.h  | 20 ++++++++-
>  .../Library/RedfishDebugLib/RedfishDebugLib.c | 41 ++++++++++++++++++-
>  2 files changed, 59 insertions(+), 2 deletions(-)
>
> diff --git a/RedfishPkg/Include/Library/RedfishDebugLib.h
> b/RedfishPkg/Include/Library/RedfishDebugLib.h
> index 5f75bad12a..3430cf1d14 100644
> --- a/RedfishPkg/Include/Library/RedfishDebugLib.h
> +++ b/RedfishPkg/Include/Library/RedfishDebugLib.h
> @@ -1,7 +1,7 @@
>  /** @file
>    This file defines the Redfish debug library interface.
>
> -  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
>
> @@ -138,4 +138,22 @@ DumpIpv4Address (
>    IN EFI_IPv4_ADDRESS  *Ipv4Address
>    );
>
> +/**
> +  Debug output raw data buffer.
> +
> +  @param[in]    ErrorLevel  DEBUG macro error level
> +  @param[in]    Buffer      Debug output data buffer.
> +  @param[in]    BufferSize  The size of Buffer in byte.
> +
> +  @retval EFI_SUCCESS             Debug dump finished.
> +  @retval EFI_INVALID_PARAMETER   Buffer is NULL.
> +
> +**/
> +EFI_STATUS
> +DumpBuffer (
> +  IN  UINTN  ErrorLevel,
> +  IN  UINT8  *Buffer,
> +  IN  UINTN  BufferSize
> +  );
> +
>  #endif
> diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
> b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
> index efa9a5ca13..5fd40ad955 100644
> --- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
> +++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
> @@ -1,7 +1,7 @@
>  /** @file
>    Redfish debug library to debug Redfish application.
>
> -  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
>
> @@ -21,6 +21,7 @@
>
>  #define REDFISH_JSON_STRING_LENGTH  200
>  #define REDFISH_JSON_OUTPUT_FORMAT  (EDKII_JSON_COMPACT |
> EDKII_JSON_INDENT(2))
> +#define REDFISH_SIZE_PER_ROW        16

How about name this as REDFISH_PRINT_BUFFER_BYTES_PER_ROW, looks more clear.

Abner

>
>  /**
>    Debug print the value of StatementValue.
> @@ -366,3 +367,41 @@ DumpIpv4Address (
>
>    return EFI_SUCCESS;
>  }
> +
> +/**
> +  Debug output raw data buffer.
> +
> +  @param[in]    ErrorLevel  DEBUG macro error level
> +  @param[in]    Buffer      Debug output data buffer.
> +  @param[in]    BufferSize  The size of Buffer in byte.
> +
> +  @retval EFI_SUCCESS             Debug dump finished.
> +  @retval EFI_INVALID_PARAMETER   Buffer is NULL.
> +
> +**/
> +EFI_STATUS
> +DumpBuffer (
> +  IN  UINTN  ErrorLevel,
> +  IN  UINT8  *Buffer,
> +  IN  UINTN  BufferSize
> +  )
> +{
> +  UINTN  Index;
> +
> +  if (Buffer == NULL) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  DEBUG ((ErrorLevel, "Address: 0x%p size: %d\n", Buffer, BufferSize));
> +  for (Index = 0; Index < BufferSize; Index++) {
> +    if (Index % REDFISH_SIZE_PER_ROW == 0) {
> +      DEBUG ((ErrorLevel, "\n%04X: ", Index));
> +    }
> +
> +    DEBUG ((ErrorLevel, "%02X ", Buffer[Index]));
> +  }
> +
> +  DEBUG ((ErrorLevel, "\n"));
> +
> +  return EFI_SUCCESS;
> +}
> --
> 2.34.1



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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [PATCH] RedfishPkg/RedfishDebugLib: add function to print buffer.
  2024-01-09  7:59 ` Chang, Abner via groups.io
@ 2024-01-09 11:14   ` Nickle Wang via groups.io
  0 siblings, 0 replies; 3+ messages in thread
From: Nickle Wang via groups.io @ 2024-01-09 11:14 UTC (permalink / raw)
  To: Chang, Abner, devel@edk2.groups.io; +Cc: Igor Kulchytskyy, Nick Ramirez

[-- Attachment #1: Type: text/plain, Size: 5980 bytes --]

Thanks for your review, @Chang, Abner<mailto:Abner.Chang@amd.com>!  Version 2 patch is sent for review here: https://edk2.groups.io/g/devel/message/113439



Regards,

Nickle



> -----Original Message-----

> From: Chang, Abner <Abner.Chang@amd.com>

> Sent: Tuesday, January 9, 2024 4:00 PM

> To: Nickle Wang <nicklew@nvidia.com>; devel@edk2.groups.io

> Cc: Igor Kulchytskyy <igork@ami.com>; Nick Ramirez <nramirez@nvidia.com>

> Subject: RE: [PATCH] RedfishPkg/RedfishDebugLib: add function to print buffer.

>

> External email: Use caution opening links or attachments

>

>

> [AMD Official Use Only - General]

>

> > -----Original Message-----

> > From: Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>

> > Sent: Tuesday, January 9, 2024 3:15 PM

> > To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>

> > Cc: Chang, Abner <Abner.Chang@amd.com<mailto:Abner.Chang@amd.com>>; Igor Kulchytskyy

> > <igork@ami.com<mailto:igork@ami.com>>; Nick Ramirez <nramirez@nvidia.com<mailto:nramirez@nvidia.com>>

> > Subject: [PATCH] RedfishPkg/RedfishDebugLib: add function to print buffer.

> >

> > Caution: This message originated from an External Source. Use proper

> > caution when opening attachments, clicking links, or responding.

> >

> >

> > Introduce DumpBuffer function to print the buffer content. This helps

> > developer to debug Redfish issue.

> >

> > Signed-off-by: Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>

> > Cc: Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>

> > Cc: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>

> > Cc: Nick Ramirez <nramirez@nvidia.com<mailto:nramirez@nvidia.com>>

> > ---

> >  RedfishPkg/Include/Library/RedfishDebugLib.h  | 20 ++++++++-

> > .../Library/RedfishDebugLib/RedfishDebugLib.c | 41 ++++++++++++++++++-

> >  2 files changed, 59 insertions(+), 2 deletions(-)

> >

> > diff --git a/RedfishPkg/Include/Library/RedfishDebugLib.h

> > b/RedfishPkg/Include/Library/RedfishDebugLib.h

> > index 5f75bad12a..3430cf1d14 100644

> > --- a/RedfishPkg/Include/Library/RedfishDebugLib.h

> > +++ b/RedfishPkg/Include/Library/RedfishDebugLib.h

> > @@ -1,7 +1,7 @@

> >  /** @file

> >    This file defines the Redfish debug library interface.

> >

> > -  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

> >

> > @@ -138,4 +138,22 @@ DumpIpv4Address (

> >    IN EFI_IPv4_ADDRESS  *Ipv4Address

> >    );

> >

> > +/**

> > +  Debug output raw data buffer.

> > +

> > +  @param[in]    ErrorLevel  DEBUG macro error level

> > +  @param[in]    Buffer      Debug output data buffer.

> > +  @param[in]    BufferSize  The size of Buffer in byte.

> > +

> > +  @retval EFI_SUCCESS             Debug dump finished.

> > +  @retval EFI_INVALID_PARAMETER   Buffer is NULL.

> > +

> > +**/

> > +EFI_STATUS

> > +DumpBuffer (

> > +  IN  UINTN  ErrorLevel,

> > +  IN  UINT8  *Buffer,

> > +  IN  UINTN  BufferSize

> > +  );

> > +

> >  #endif

> > diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c

> > b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c

> > index efa9a5ca13..5fd40ad955 100644

> > --- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c

> > +++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c

> > @@ -1,7 +1,7 @@

> >  /** @file

> >    Redfish debug library to debug Redfish application.

> >

> > -  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

> >

> > @@ -21,6 +21,7 @@

> >

> >  #define REDFISH_JSON_STRING_LENGTH  200  #define

> > REDFISH_JSON_OUTPUT_FORMAT  (EDKII_JSON_COMPACT |

> > EDKII_JSON_INDENT(2))

> > +#define REDFISH_SIZE_PER_ROW        16

>

> How about name this as REDFISH_PRINT_BUFFER_BYTES_PER_ROW, looks more

> clear.

>

> Abner

>

> >

> >  /**

> >    Debug print the value of StatementValue.

> > @@ -366,3 +367,41 @@ DumpIpv4Address (

> >

> >    return EFI_SUCCESS;

> >  }

> > +

> > +/**

> > +  Debug output raw data buffer.

> > +

> > +  @param[in]    ErrorLevel  DEBUG macro error level

> > +  @param[in]    Buffer      Debug output data buffer.

> > +  @param[in]    BufferSize  The size of Buffer in byte.

> > +

> > +  @retval EFI_SUCCESS             Debug dump finished.

> > +  @retval EFI_INVALID_PARAMETER   Buffer is NULL.

> > +

> > +**/

> > +EFI_STATUS

> > +DumpBuffer (

> > +  IN  UINTN  ErrorLevel,

> > +  IN  UINT8  *Buffer,

> > +  IN  UINTN  BufferSize

> > +  )

> > +{

> > +  UINTN  Index;

> > +

> > +  if (Buffer == NULL) {

> > +    return EFI_INVALID_PARAMETER;

> > +  }

> > +

> > +  DEBUG ((ErrorLevel, "Address: 0x%p size: %d\n", Buffer,

> > + BufferSize));  for (Index = 0; Index < BufferSize; Index++) {

> > +    if (Index % REDFISH_SIZE_PER_ROW == 0) {

> > +      DEBUG ((ErrorLevel, "\n%04X: ", Index));

> > +    }

> > +

> > +    DEBUG ((ErrorLevel, "%02X ", Buffer[Index]));  }

> > +

> > +  DEBUG ((ErrorLevel, "\n"));

> > +

> > +  return EFI_SUCCESS;

> > +}

> > --

> > 2.34.1




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



[-- Attachment #2: Type: text/html, Size: 14829 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-09 11:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-09  7:14 [edk2-devel] [PATCH] RedfishPkg/RedfishDebugLib: add function to print buffer Nickle Wang via groups.io
2024-01-09  7:59 ` Chang, Abner via groups.io
2024-01-09 11:14   ` Nickle Wang via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox