net: implement netif_cond_dbg macro
authorEdward Cree <ecree@solarflare.com>
Fri, 27 Jan 2017 15:02:26 +0000 (15:02 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 27 Jan 2017 16:59:31 +0000 (11:59 -0500)
For reporting things that may or may not be serious, depending on some
 condition, netif_cond_dbg will check the condition and print the report
 at either dbg (if the condition is true) or the specified level.

Suggested-by: Jon Cooper <jcooper@solarflare.com>
Signed-off-by: Edward Cree <ecree@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netdevice.h

index d63cacb67ea668309e63a06f2bb6176a7f23bea8..9511e5a1cfc64fa58b764949f99f8cb15520de7a 100644 (file)
@@ -4347,6 +4347,15 @@ do {                                                             \
 })
 #endif
 
+/* if @cond then downgrade to debug, else print at @level */
+#define netif_cond_dbg(priv, type, netdev, cond, level, fmt, args...)     \
+       do {                                                              \
+               if (cond)                                                 \
+                       netif_dbg(priv, type, netdev, fmt, ##args);       \
+               else                                                      \
+                       netif_ ## level(priv, type, netdev, fmt, ##args); \
+       } while (0)
+
 #if defined(VERBOSE_DEBUG)
 #define netif_vdbg     netif_dbg
 #else