linux/include/net/net_debug.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_NET_DEBUG_H
#define _LINUX_NET_DEBUG_H

#include <linux/bug.h>
#include <linux/kern_levels.h>

struct net_device;

__printf(3, 4) __cold
void netdev_printk(const char *level, const struct net_device *dev,
		   const char *format, ...);
__printf(2, 3) __cold
void netdev_emerg(const struct net_device *dev, const char *format, ...);
__printf(2, 3) __cold
void netdev_alert(const struct net_device *dev, const char *format, ...);
__printf(2, 3) __cold
void netdev_crit(const struct net_device *dev, const char *format, ...);
__printf(2, 3) __cold
void netdev_err(const struct net_device *dev, const char *format, ...);
__printf(2, 3) __cold
void netdev_warn(const struct net_device *dev, const char *format, ...);
__printf(2, 3) __cold
void netdev_notice(const struct net_device *dev, const char *format, ...);
__printf(2, 3) __cold
void netdev_info(const struct net_device *dev, const char *format, ...);

#define netdev_level_once(level, dev, fmt, ...)

#define netdev_emerg_once(dev, fmt, ...)
#define netdev_alert_once(dev, fmt, ...)
#define netdev_crit_once(dev, fmt, ...)
#define netdev_err_once(dev, fmt, ...)
#define netdev_warn_once(dev, fmt, ...)
#define netdev_notice_once(dev, fmt, ...)
#define netdev_info_once(dev, fmt, ...)

#if defined(CONFIG_DYNAMIC_DEBUG) || \
	(defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
#define netdev_dbg(__dev, format, args...)
#elif defined(DEBUG)
#define netdev_dbg
#else
#define netdev_dbg
#endif

#if defined(VERBOSE_DEBUG)
#define netdev_vdbg
#else

#define netdev_vdbg(dev, format, args...)
#endif

/* netif printk helpers, similar to netdev_printk */

#define netif_printk(priv, type, level, dev, fmt, args...)

#define netif_level(level, priv, type, dev, fmt, args...)

#define netif_emerg(priv, type, dev, fmt, args...)
#define netif_alert(priv, type, dev, fmt, args...)
#define netif_crit(priv, type, dev, fmt, args...)
#define netif_err(priv, type, dev, fmt, args...)
#define netif_warn(priv, type, dev, fmt, args...)
#define netif_notice(priv, type, dev, fmt, args...)
#define netif_info(priv, type, dev, fmt, args...)

#if defined(CONFIG_DYNAMIC_DEBUG) || \
	(defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
#define netif_dbg(priv, type, netdev, format, args...)
#elif defined(DEBUG)
#define netif_dbg
#else
#define netif_dbg
#endif

/* if @cond then downgrade to debug, else print at @level */
#define netif_cond_dbg(priv, type, netdev, cond, level, fmt, args...)

#if defined(VERBOSE_DEBUG)
#define netif_vdbg
#else
#define netif_vdbg(priv, type, dev, format, args...)
#endif


#if defined(CONFIG_DEBUG_NET)
#define DEBUG_NET_WARN_ON_ONCE(cond)
#else
#define DEBUG_NET_WARN_ON_ONCE
#endif

#endif	/* _LINUX_NET_DEBUG_H */