~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/batman-adv/log.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /* Copyright (C) B.A.T.M.A.N. contributors:
  3  *
  4  * Marek Lindner, Simon Wunderlich
  5  */
  6 
  7 #ifndef _NET_BATMAN_ADV_LOG_H_
  8 #define _NET_BATMAN_ADV_LOG_H_
  9 
 10 #include "main.h"
 11 
 12 #include <linux/atomic.h>
 13 #include <linux/bitops.h>
 14 #include <linux/compiler.h>
 15 #include <linux/printk.h>
 16 
 17 #ifdef CONFIG_BATMAN_ADV_DEBUG
 18 
 19 int batadv_debug_log_setup(struct batadv_priv *bat_priv);
 20 void batadv_debug_log_cleanup(struct batadv_priv *bat_priv);
 21 
 22 #else
 23 
 24 static inline int batadv_debug_log_setup(struct batadv_priv *bat_priv)
 25 {
 26         return 0;
 27 }
 28 
 29 static inline void batadv_debug_log_cleanup(struct batadv_priv *bat_priv)
 30 {
 31 }
 32 
 33 #endif
 34 
 35 /**
 36  * enum batadv_dbg_level - available log levels
 37  */
 38 enum batadv_dbg_level {
 39         /** @BATADV_DBG_BATMAN: OGM and TQ computations related messages */
 40         BATADV_DBG_BATMAN       = BIT(0),
 41 
 42         /** @BATADV_DBG_ROUTES: route added / changed / deleted */
 43         BATADV_DBG_ROUTES       = BIT(1),
 44 
 45         /** @BATADV_DBG_TT: translation table messages */
 46         BATADV_DBG_TT           = BIT(2),
 47 
 48         /** @BATADV_DBG_BLA: bridge loop avoidance messages */
 49         BATADV_DBG_BLA          = BIT(3),
 50 
 51         /** @BATADV_DBG_DAT: ARP snooping and DAT related messages */
 52         BATADV_DBG_DAT          = BIT(4),
 53 
 54         /** @BATADV_DBG_NC: network coding related messages */
 55         BATADV_DBG_NC           = BIT(5),
 56 
 57         /** @BATADV_DBG_MCAST: multicast related messages */
 58         BATADV_DBG_MCAST        = BIT(6),
 59 
 60         /** @BATADV_DBG_TP_METER: throughput meter messages */
 61         BATADV_DBG_TP_METER     = BIT(7),
 62 
 63         /** @BATADV_DBG_ALL: the union of all the above log levels */
 64         BATADV_DBG_ALL          = 255,
 65 };
 66 
 67 #ifdef CONFIG_BATMAN_ADV_DEBUG
 68 int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
 69 __printf(2, 3);
 70 
 71 /**
 72  * _batadv_dbg() - Store debug output with(out) rate limiting
 73  * @type: type of debug message
 74  * @bat_priv: the bat priv with all the soft interface information
 75  * @ratelimited: whether output should be rate limited
 76  * @fmt: format string
 77  * @arg: variable arguments
 78  */
 79 #define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...)           \
 80         do {                                                            \
 81                 struct batadv_priv *__batpriv = (bat_priv);             \
 82                 if (atomic_read(&__batpriv->log_level) & (type) &&      \
 83                     (!(ratelimited) || net_ratelimit()))                \
 84                         batadv_debug_log(__batpriv, fmt, ## arg);       \
 85         }                                                               \
 86         while (0)
 87 #else /* !CONFIG_BATMAN_ADV_DEBUG */
 88 __printf(4, 5)
 89 static inline void _batadv_dbg(int type __always_unused,
 90                                struct batadv_priv *bat_priv __always_unused,
 91                                int ratelimited __always_unused,
 92                                const char *fmt __always_unused, ...)
 93 {
 94 }
 95 #endif
 96 
 97 /**
 98  * batadv_dbg() - Store debug output without rate limiting
 99  * @type: type of debug message
100  * @bat_priv: the bat priv with all the soft interface information
101  * @arg: format string and variable arguments
102  */
103 #define batadv_dbg(type, bat_priv, arg...) \
104         _batadv_dbg(type, bat_priv, 0, ## arg)
105 
106 /**
107  * batadv_dbg_ratelimited() - Store debug output with rate limiting
108  * @type: type of debug message
109  * @bat_priv: the bat priv with all the soft interface information
110  * @arg: format string and variable arguments
111  */
112 #define batadv_dbg_ratelimited(type, bat_priv, arg...) \
113         _batadv_dbg(type, bat_priv, 1, ## arg)
114 
115 /**
116  * batadv_info() - Store message in debug buffer and print it to kmsg buffer
117  * @net_dev: the soft interface net device
118  * @fmt: format string
119  * @arg: variable arguments
120  */
121 #define batadv_info(net_dev, fmt, arg...)                               \
122         do {                                                            \
123                 struct net_device *_netdev = (net_dev);                 \
124                 struct batadv_priv *_batpriv = netdev_priv(_netdev);    \
125                 batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg);      \
126                 pr_info("%s: " fmt, _netdev->name, ## arg);             \
127         } while (0)
128 
129 /**
130  * batadv_err() - Store error in debug buffer and print it to kmsg buffer
131  * @net_dev: the soft interface net device
132  * @fmt: format string
133  * @arg: variable arguments
134  */
135 #define batadv_err(net_dev, fmt, arg...)                                \
136         do {                                                            \
137                 struct net_device *_netdev = (net_dev);                 \
138                 struct batadv_priv *_batpriv = netdev_priv(_netdev);    \
139                 batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg);      \
140                 pr_err("%s: " fmt, _netdev->name, ## arg);              \
141         } while (0)
142 
143 #endif /* _NET_BATMAN_ADV_LOG_H_ */
144 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php