[dpdk-dev] enic: disable debug traces

Message ID 1428428419-25145-1-git-send-email-thomas.monjalon@6wind.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Thomas Monjalon April 7, 2015, 5:40 p.m. UTC
  The function name is printed in each enic_ethdev function.
Disable it by default with a new build option.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
 config/common_bsdapp              | 1 +
 config/common_linuxapp            | 1 +
 lib/librte_pmd_enic/enic_ethdev.c | 4 ++++
 3 files changed, 6 insertions(+)
  

Comments

Sujith Sankar April 8, 2015, 3:29 a.m. UTC | #1
On 07/04/15 11:10 pm, "Thomas Monjalon" <thomas.monjalon@6wind.com> wrote:

>The function name is printed in each enic_ethdev function.
>Disable it by default with a new build option.
>
>Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
>---
> config/common_bsdapp              | 1 +
> config/common_linuxapp            | 1 +
> lib/librte_pmd_enic/enic_ethdev.c | 4 ++++
> 3 files changed, 6 insertions(+)
>
>diff --git a/config/common_bsdapp b/config/common_bsdapp
>index a8ba484..c2374c0 100644
>--- a/config/common_bsdapp
>+++ b/config/common_bsdapp
>@@ -214,6 +214,7 @@ CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS=1
> # Compile burst-oriented Cisco ENIC PMD driver
> #
> CONFIG_RTE_LIBRTE_ENIC_PMD=y
>+CONFIG_RTE_LIBRTE_ENIC_DEBUG=n
> 
> #
> # Compile burst-oriented VIRTIO PMD driver
>diff --git a/config/common_linuxapp b/config/common_linuxapp
>index 0b25f34..0078dc9 100644
>--- a/config/common_linuxapp
>+++ b/config/common_linuxapp
>@@ -211,6 +211,7 @@ CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS=1
> # Compile burst-oriented Cisco ENIC PMD driver
> #
> CONFIG_RTE_LIBRTE_ENIC_PMD=y
>+CONFIG_RTE_LIBRTE_ENIC_DEBUG=n
> 
> #
> # Compile burst-oriented VIRTIO PMD driver
>diff --git a/lib/librte_pmd_enic/enic_ethdev.c
>b/lib/librte_pmd_enic/enic_ethdev.c
>index 4950ede..18fadfb 100644
>--- a/lib/librte_pmd_enic/enic_ethdev.c
>+++ b/lib/librte_pmd_enic/enic_ethdev.c
>@@ -48,8 +48,12 @@
> #include "vnic_enet.h"
> #include "enic.h"
> 
>+#ifdef RTE_LIBRTE_ENIC_DEBUG
> #define ENICPMD_FUNC_TRACE() \
> 	RTE_LOG(DEBUG, PMD, "ENICPMD trace: %s\n", __func__)
>+#else
>+#define ENICPMD_FUNC_TRACE() do {} while (0)
>+#endif
> 
> /*
>  * The set of PCI devices this driver supports
>-- 
>2.2.2
>
Acked-by: Sujith Sankar <ssujith@cisco.com>
>
  
Adrien Mazarguil April 9, 2015, 8:32 a.m. UTC | #2
On Tue, Apr 07, 2015 at 07:40:19PM +0200, Thomas Monjalon wrote:
> The function name is printed in each enic_ethdev function.
> Disable it by default with a new build option.
> 
> Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
> ---
>  config/common_bsdapp              | 1 +
>  config/common_linuxapp            | 1 +
>  lib/librte_pmd_enic/enic_ethdev.c | 4 ++++
>  3 files changed, 6 insertions(+)
> 
> diff --git a/config/common_bsdapp b/config/common_bsdapp
> index a8ba484..c2374c0 100644
> --- a/config/common_bsdapp
> +++ b/config/common_bsdapp
> @@ -214,6 +214,7 @@ CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS=1
>  # Compile burst-oriented Cisco ENIC PMD driver
>  #
>  CONFIG_RTE_LIBRTE_ENIC_PMD=y
> +CONFIG_RTE_LIBRTE_ENIC_DEBUG=n
>  
>  #
>  # Compile burst-oriented VIRTIO PMD driver
> diff --git a/config/common_linuxapp b/config/common_linuxapp
> index 0b25f34..0078dc9 100644
> --- a/config/common_linuxapp
> +++ b/config/common_linuxapp
> @@ -211,6 +211,7 @@ CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS=1
>  # Compile burst-oriented Cisco ENIC PMD driver
>  #
>  CONFIG_RTE_LIBRTE_ENIC_PMD=y
> +CONFIG_RTE_LIBRTE_ENIC_DEBUG=n
>  
>  #
>  # Compile burst-oriented VIRTIO PMD driver
> diff --git a/lib/librte_pmd_enic/enic_ethdev.c b/lib/librte_pmd_enic/enic_ethdev.c
> index 4950ede..18fadfb 100644
> --- a/lib/librte_pmd_enic/enic_ethdev.c
> +++ b/lib/librte_pmd_enic/enic_ethdev.c
> @@ -48,8 +48,12 @@
>  #include "vnic_enet.h"
>  #include "enic.h"
>  
> +#ifdef RTE_LIBRTE_ENIC_DEBUG
>  #define ENICPMD_FUNC_TRACE() \
>  	RTE_LOG(DEBUG, PMD, "ENICPMD trace: %s\n", __func__)
> +#else
> +#define ENICPMD_FUNC_TRACE() do {} while (0)

How about defining it as (void)0 instead of an empty do/while block?

Doing so will prevent warnings if this macro happens to be used in an
expression. RTE_LOG() supports it.

> +#endif
>  
>  /*
>   * The set of PCI devices this driver supports
> -- 
> 2.2.2
  
Stephen Hemminger April 9, 2015, 4:28 p.m. UTC | #3
On Thu, 9 Apr 2015 10:32:24 +0200
Adrien Mazarguil <adrien.mazarguil@6wind.com> wrote:

> >  
> > +#ifdef RTE_LIBRTE_ENIC_DEBUG
> >  #define ENICPMD_FUNC_TRACE() \
> >  	RTE_LOG(DEBUG, PMD, "ENICPMD trace: %s\n", __func__)
> > +#else
> > +#define ENICPMD_FUNC_TRACE() do {} while (0)  
> 
> How about defining it as (void)0 instead of an empty do/while block?
> 
> Doing so will prevent warnings if this macro happens to be used in an
> expression. RTE_LOG() supports it.

I kind of like the Linux printk trick since it then preserves the format checking
even if compiled out.

/*
 * Dummy printk for disabled debugging statements to use whilst maintaining
 * gcc's format and side-effect checking.
 */
static inline __printf(1, 2)
int no_printk(const char *fmt, ...)
{
	return 0;
}

/* pr_devel() should produce zero code unless DEBUG is defined */
#ifdef DEBUG
#define pr_devel(fmt, ...) \
	printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#else
#define pr_devel(fmt, ...) \
	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#endif
  
Adrien Mazarguil April 13, 2015, 10:32 a.m. UTC | #4
On Thu, Apr 09, 2015 at 09:28:53AM -0700, Stephen Hemminger wrote:
> On Thu, 9 Apr 2015 10:32:24 +0200
> Adrien Mazarguil <adrien.mazarguil@6wind.com> wrote:
> 
> > >  
> > > +#ifdef RTE_LIBRTE_ENIC_DEBUG
> > >  #define ENICPMD_FUNC_TRACE() \
> > >  	RTE_LOG(DEBUG, PMD, "ENICPMD trace: %s\n", __func__)
> > > +#else
> > > +#define ENICPMD_FUNC_TRACE() do {} while (0)  
> > 
> > How about defining it as (void)0 instead of an empty do/while block?
> > 
> > Doing so will prevent warnings if this macro happens to be used in an
> > expression. RTE_LOG() supports it.
> 
> I kind of like the Linux printk trick since it then preserves the format checking
> even if compiled out.
> 
> /*
>  * Dummy printk for disabled debugging statements to use whilst maintaining
>  * gcc's format and side-effect checking.
>  */
> static inline __printf(1, 2)
> int no_printk(const char *fmt, ...)
> {
> 	return 0;
> }
> 
> /* pr_devel() should produce zero code unless DEBUG is defined */
> #ifdef DEBUG
> #define pr_devel(fmt, ...) \
> 	printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
> #else
> #define pr_devel(fmt, ...) \
> 	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
> #endif

My only concern with this is that it cannot be done in a ISO C compliant
manner easily.

While "__printf()" can be defined to nothing when dealing with compilers
that do not support extensions, ", ## __VAR_ARGS__" will most likely fail
with -pedantic.
  
Thomas Monjalon April 13, 2015, 8:12 p.m. UTC | #5
2015-04-09 10:32, Adrien Mazarguil:
> On Tue, Apr 07, 2015 at 07:40:19PM +0200, Thomas Monjalon wrote:
> > The function name is printed in each enic_ethdev function.
> > Disable it by default with a new build option.
> > 
> > Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
[...]
> > --- a/lib/librte_pmd_enic/enic_ethdev.c
> > +++ b/lib/librte_pmd_enic/enic_ethdev.c
> > @@ -48,8 +48,12 @@
> >  #include "vnic_enet.h"
> >  #include "enic.h"
> >  
> > +#ifdef RTE_LIBRTE_ENIC_DEBUG
> >  #define ENICPMD_FUNC_TRACE() \
> >  	RTE_LOG(DEBUG, PMD, "ENICPMD trace: %s\n", __func__)
> > +#else
> > +#define ENICPMD_FUNC_TRACE() do {} while (0)
> 
> How about defining it as (void)0 instead of an empty do/while block?
> 
> Doing so will prevent warnings if this macro happens to be used in an
> expression. RTE_LOG() supports it.

Applied with Adrien's suggestion.
  

Patch

diff --git a/config/common_bsdapp b/config/common_bsdapp
index a8ba484..c2374c0 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -214,6 +214,7 @@  CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS=1
 # Compile burst-oriented Cisco ENIC PMD driver
 #
 CONFIG_RTE_LIBRTE_ENIC_PMD=y
+CONFIG_RTE_LIBRTE_ENIC_DEBUG=n
 
 #
 # Compile burst-oriented VIRTIO PMD driver
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 0b25f34..0078dc9 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -211,6 +211,7 @@  CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS=1
 # Compile burst-oriented Cisco ENIC PMD driver
 #
 CONFIG_RTE_LIBRTE_ENIC_PMD=y
+CONFIG_RTE_LIBRTE_ENIC_DEBUG=n
 
 #
 # Compile burst-oriented VIRTIO PMD driver
diff --git a/lib/librte_pmd_enic/enic_ethdev.c b/lib/librte_pmd_enic/enic_ethdev.c
index 4950ede..18fadfb 100644
--- a/lib/librte_pmd_enic/enic_ethdev.c
+++ b/lib/librte_pmd_enic/enic_ethdev.c
@@ -48,8 +48,12 @@ 
 #include "vnic_enet.h"
 #include "enic.h"
 
+#ifdef RTE_LIBRTE_ENIC_DEBUG
 #define ENICPMD_FUNC_TRACE() \
 	RTE_LOG(DEBUG, PMD, "ENICPMD trace: %s\n", __func__)
+#else
+#define ENICPMD_FUNC_TRACE() do {} while (0)
+#endif
 
 /*
  * The set of PCI devices this driver supports