Netdev List
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Jeff Kirsher <jeffrey.t.kirsher@intel.com>, davem@davemloft.net
Cc: netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	Andrew Bowers <andrewx.bowers@intel.com>
Subject: Re: [net-next 08/15] iavf: Fix up debug print macro
Date: Sat, 29 Jun 2019 13:42:06 -0700	[thread overview]
Message-ID: <9408eb59ecaa3e245fd71ec0211a34c3fb0e324b.camel@perches.com> (raw)
In-Reply-To: <20190628224932.3389-9-jeffrey.t.kirsher@intel.com>

On Fri, 2019-06-28 at 15:49 -0700, Jeff Kirsher wrote:
> This aligns the iavf_debug() macro with the other Intel drivers.
> 
> Add the bus number, bus_id field to i40e_bus_info so output shows
> each physical port(i.e func) in following format:
>   [[[[<domain>]:]<bus>]:][<slot>][.[<func>]]
> domains are numbered from 0 to ffff), bus (0-ff), slot (0-1f) and
> function (0-7).
> 
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
> ---
>  drivers/net/ethernet/intel/iavf/iavf_osdep.h | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_osdep.h b/drivers/net/ethernet/intel/iavf/iavf_osdep.h
> index d39684558597..a452ce90679a 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_osdep.h
> +++ b/drivers/net/ethernet/intel/iavf/iavf_osdep.h
> @@ -44,8 +44,12 @@ struct iavf_virt_mem {
>  #define iavf_allocate_virt_mem(h, m, s) iavf_allocate_virt_mem_d(h, m, s)
>  #define iavf_free_virt_mem(h, m) iavf_free_virt_mem_d(h, m)
>  
> -#define iavf_debug(h, m, s, ...)  iavf_debug_d(h, m, s, ##__VA_ARGS__)
> -extern void iavf_debug_d(void *hw, u32 mask, char *fmt_str, ...)
> -	__printf(3, 4);
> +#define iavf_debug(h, m, s, ...)				\
> +do {								\
> +	if (((m) & (h)->debug_mask))				\
> +		pr_info("iavf %02x:%02x.%x " s,			\
> +			(h)->bus.bus_id, (h)->bus.device,	\
> +			(h)->bus.func, ##__VA_ARGS__);		\
> +} while (0)

Why not change the function to do this?

And if this is really wanted this particular way
the now unused function should be removed too.

But I suggest emitting at KERN_DEBUG and using
the more typical %pV vsprintf extension.

---

 drivers/net/ethernet/intel/iavf/iavf_main.c  | 25 ++++++++++++++-----------
 drivers/net/ethernet/intel/iavf/iavf_osdep.h |  9 ++++++---
 2 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index 881561b36083..8504fd71d398 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -143,25 +143,28 @@ enum iavf_status iavf_free_virt_mem_d(struct iavf_hw *hw,
 }
 
 /**
- * iavf_debug_d - OS dependent version of debug printing
+ * _iavf_debug - OS dependent version of debug printing
  * @hw:  pointer to the HW structure
  * @mask: debug level mask
- * @fmt_str: printf-type format description
+ * @fmt: printf-type format description
  **/
-void iavf_debug_d(void *hw, u32 mask, char *fmt_str, ...)
+void _iavf_debug(const struct iavf_hw *hw, u32 mask, const char *fmt, ...)
 {
-	char buf[512];
-	va_list argptr;
+	struct va_format vaf;
+	va_list args;
 
-	if (!(mask & ((struct iavf_hw *)hw)->debug_mask))
+	if (!(hw->debug_mask & mask))
 		return;
 
-	va_start(argptr, fmt_str);
-	vsnprintf(buf, sizeof(buf), fmt_str, argptr);
-	va_end(argptr);
+	va_start(args, fmt);
 
-	/* the debug string is already formatted with a newline */
-	pr_info("%s", buf);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	pr_debug("iavf %02x:%02x.%x %pV",
+		 hw->bus.bus_id, hw->bus.device, hw->bus.func, &vaf);
+
+	va_end(args);
 }
 
 /**
diff --git a/drivers/net/ethernet/intel/iavf/iavf_osdep.h b/drivers/net/ethernet/intel/iavf/iavf_osdep.h
index d39684558597..0e6ac7d262c8 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_osdep.h
+++ b/drivers/net/ethernet/intel/iavf/iavf_osdep.h
@@ -44,8 +44,11 @@ struct iavf_virt_mem {
 #define iavf_allocate_virt_mem(h, m, s) iavf_allocate_virt_mem_d(h, m, s)
 #define iavf_free_virt_mem(h, m) iavf_free_virt_mem_d(h, m)
 
-#define iavf_debug(h, m, s, ...)  iavf_debug_d(h, m, s, ##__VA_ARGS__)
-extern void iavf_debug_d(void *hw, u32 mask, char *fmt_str, ...)
-	__printf(3, 4);
+struct iavf_hw;
+
+__printf(3, 4)
+void _iavf_debug(const struct iavf_hw *hw, u32 mask, const char *fmt, ...);
+#define iavf_debug(hw, mask, fmt, ...)					\
+	_iavf_debug(hw, mask, fmt, ##__VA_ARGS__)
 
 #endif /* _IAVF_OSDEP_H_ */



  reply	other threads:[~2019-06-29 20:42 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-28 22:49 [net-next 00/15][pull request] Intel Wired LAN Driver Updates 2019-06-28 Jeff Kirsher
2019-06-28 22:49 ` [net-next 01/15] ice: Use struct_size() helper Jeff Kirsher
2019-06-28 22:49 ` [net-next 02/15] e1000e: Increase pause and refresh time Jeff Kirsher
2019-06-28 22:49 ` [net-next 03/15] ixgbe: Avoid NULL pointer dereference with VF on non-IPsec hw Jeff Kirsher
2019-06-28 22:55   ` Shannon Nelson
2019-06-28 22:49 ` [net-next 04/15] ixgbe: fix potential u32 overflow on shift Jeff Kirsher
2019-06-28 22:49 ` [net-next 05/15] e1000: Use dma_wmb() instead of wmb() before doorbell writes Jeff Kirsher
2019-06-28 22:49 ` [net-next 06/15] iavf: use struct_size() helper Jeff Kirsher
2019-06-28 22:49 ` [net-next 07/15] e1000e: Reduce boot time by tightening sleep ranges Jeff Kirsher
2019-06-28 22:49 ` [net-next 08/15] iavf: Fix up debug print macro Jeff Kirsher
2019-06-29 20:42   ` Joe Perches [this message]
2019-07-01 17:27     ` Jeff Kirsher
2019-06-28 22:49 ` [net-next 09/15] igb: minor ethool regdump amendment Jeff Kirsher
2019-06-28 22:49 ` [net-next 10/15] igb: add RR2DCDELAY to ethtool registers dump Jeff Kirsher
2019-06-28 22:49 ` [net-next 11/15] iavf: fix dereference of null rx_buffer pointer Jeff Kirsher
2019-06-28 22:49 ` [net-next 12/15] ixgbevf: Use cached link state instead of re-reading the value for ethtool Jeff Kirsher
2019-06-28 22:49 ` [net-next 13/15] i40e: Add macvlan support on i40e Jeff Kirsher
2019-06-28 22:49 ` [net-next 14/15] e1000e: Make watchdog use delayed work Jeff Kirsher
2019-06-28 22:49 ` [net-next 15/15] e1000e: PCIm function state support Jeff Kirsher
2019-06-30 23:05 ` [net-next 00/15][pull request] Intel Wired LAN Driver Updates 2019-06-28 David Miller

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-all 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=9408eb59ecaa3e245fd71ec0211a34c3fb0e324b.camel@perches.com \
    --to=joe@perches.com \
    --cc=andrewx.bowers@intel.com \
    --cc=davem@davemloft.net \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.com \
    /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