drm/panel-edp: Add STA 116QHD024002
[drm/drm-misc.git] / include / net / net_debug.h
blob47f7a4a878b9f3f52d6c55a13e8c19bbd7f8edcf
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_NET_DEBUG_H
3 #define _LINUX_NET_DEBUG_H
5 #include <linux/bug.h>
6 #include <linux/kern_levels.h>
8 struct net_device;
10 __printf(3, 4) __cold
11 void netdev_printk(const char *level, const struct net_device *dev,
12 const char *format, ...);
13 __printf(2, 3) __cold
14 void netdev_emerg(const struct net_device *dev, const char *format, ...);
15 __printf(2, 3) __cold
16 void netdev_alert(const struct net_device *dev, const char *format, ...);
17 __printf(2, 3) __cold
18 void netdev_crit(const struct net_device *dev, const char *format, ...);
19 __printf(2, 3) __cold
20 void netdev_err(const struct net_device *dev, const char *format, ...);
21 __printf(2, 3) __cold
22 void netdev_warn(const struct net_device *dev, const char *format, ...);
23 __printf(2, 3) __cold
24 void netdev_notice(const struct net_device *dev, const char *format, ...);
25 __printf(2, 3) __cold
26 void netdev_info(const struct net_device *dev, const char *format, ...);
28 #define netdev_level_once(level, dev, fmt, ...) \
29 do { \
30 static bool __section(".data..once") __print_once; \
32 if (!__print_once) { \
33 __print_once = true; \
34 netdev_printk(level, dev, fmt, ##__VA_ARGS__); \
35 } \
36 } while (0)
38 #define netdev_emerg_once(dev, fmt, ...) \
39 netdev_level_once(KERN_EMERG, dev, fmt, ##__VA_ARGS__)
40 #define netdev_alert_once(dev, fmt, ...) \
41 netdev_level_once(KERN_ALERT, dev, fmt, ##__VA_ARGS__)
42 #define netdev_crit_once(dev, fmt, ...) \
43 netdev_level_once(KERN_CRIT, dev, fmt, ##__VA_ARGS__)
44 #define netdev_err_once(dev, fmt, ...) \
45 netdev_level_once(KERN_ERR, dev, fmt, ##__VA_ARGS__)
46 #define netdev_warn_once(dev, fmt, ...) \
47 netdev_level_once(KERN_WARNING, dev, fmt, ##__VA_ARGS__)
48 #define netdev_notice_once(dev, fmt, ...) \
49 netdev_level_once(KERN_NOTICE, dev, fmt, ##__VA_ARGS__)
50 #define netdev_info_once(dev, fmt, ...) \
51 netdev_level_once(KERN_INFO, dev, fmt, ##__VA_ARGS__)
53 #if defined(CONFIG_DYNAMIC_DEBUG) || \
54 (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
55 #define netdev_dbg(__dev, format, args...) \
56 do { \
57 dynamic_netdev_dbg(__dev, format, ##args); \
58 } while (0)
59 #elif defined(DEBUG)
60 #define netdev_dbg(__dev, format, args...) \
61 netdev_printk(KERN_DEBUG, __dev, format, ##args)
62 #else
63 #define netdev_dbg(__dev, format, args...) \
64 ({ \
65 if (0) \
66 netdev_printk(KERN_DEBUG, __dev, format, ##args); \
68 #endif
70 #if defined(VERBOSE_DEBUG)
71 #define netdev_vdbg netdev_dbg
72 #else
74 #define netdev_vdbg(dev, format, args...) \
75 ({ \
76 if (0) \
77 netdev_printk(KERN_DEBUG, dev, format, ##args); \
78 0; \
80 #endif
82 /* netif printk helpers, similar to netdev_printk */
84 #define netif_printk(priv, type, level, dev, fmt, args...) \
85 do { \
86 if (netif_msg_##type(priv)) \
87 netdev_printk(level, (dev), fmt, ##args); \
88 } while (0)
90 #define netif_level(level, priv, type, dev, fmt, args...) \
91 do { \
92 if (netif_msg_##type(priv)) \
93 netdev_##level(dev, fmt, ##args); \
94 } while (0)
96 #define netif_emerg(priv, type, dev, fmt, args...) \
97 netif_level(emerg, priv, type, dev, fmt, ##args)
98 #define netif_alert(priv, type, dev, fmt, args...) \
99 netif_level(alert, priv, type, dev, fmt, ##args)
100 #define netif_crit(priv, type, dev, fmt, args...) \
101 netif_level(crit, priv, type, dev, fmt, ##args)
102 #define netif_err(priv, type, dev, fmt, args...) \
103 netif_level(err, priv, type, dev, fmt, ##args)
104 #define netif_warn(priv, type, dev, fmt, args...) \
105 netif_level(warn, priv, type, dev, fmt, ##args)
106 #define netif_notice(priv, type, dev, fmt, args...) \
107 netif_level(notice, priv, type, dev, fmt, ##args)
108 #define netif_info(priv, type, dev, fmt, args...) \
109 netif_level(info, priv, type, dev, fmt, ##args)
111 #if defined(CONFIG_DYNAMIC_DEBUG) || \
112 (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
113 #define netif_dbg(priv, type, netdev, format, args...) \
114 do { \
115 if (netif_msg_##type(priv)) \
116 dynamic_netdev_dbg(netdev, format, ##args); \
117 } while (0)
118 #elif defined(DEBUG)
119 #define netif_dbg(priv, type, dev, format, args...) \
120 netif_printk(priv, type, KERN_DEBUG, dev, format, ##args)
121 #else
122 #define netif_dbg(priv, type, dev, format, args...) \
123 ({ \
124 if (0) \
125 netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \
126 0; \
128 #endif
130 /* if @cond then downgrade to debug, else print at @level */
131 #define netif_cond_dbg(priv, type, netdev, cond, level, fmt, args...) \
132 do { \
133 if (cond) \
134 netif_dbg(priv, type, netdev, fmt, ##args); \
135 else \
136 netif_ ## level(priv, type, netdev, fmt, ##args); \
137 } while (0)
139 #if defined(VERBOSE_DEBUG)
140 #define netif_vdbg netif_dbg
141 #else
142 #define netif_vdbg(priv, type, dev, format, args...) \
143 ({ \
144 if (0) \
145 netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \
146 0; \
148 #endif
151 #if defined(CONFIG_DEBUG_NET)
152 #define DEBUG_NET_WARN_ON_ONCE(cond) ((void)WARN_ON_ONCE(cond))
153 #define DEBUG_NET_WARN_ONCE(cond, format...) ((void)WARN_ONCE(cond, format))
154 #else
155 #define DEBUG_NET_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond)
156 #define DEBUG_NET_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond)
157 #endif
159 #endif /* _LINUX_NET_DEBUG_H */