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

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

Version: ~ [ linux-5.12-rc1 ] ~ [ linux-5.11.2 ] ~ [ linux-5.10.19 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.101 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.177 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.222 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.258 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.258 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ 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.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* Copyright (C) 2007-2017  B.A.T.M.A.N. contributors:
  2  *
  3  * Marek Lindner, Simon Wunderlich
  4  *
  5  * This program is free software; you can redistribute it and/or
  6  * modify it under the terms of version 2 of the GNU General Public
  7  * License as published by the Free Software Foundation.
  8  *
  9  * This program is distributed in the hope that it will be useful, but
 10  * WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12  * General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU General Public License
 15  * along with this program; if not, see <http://www.gnu.org/licenses/>.
 16  */
 17 
 18 #ifndef _NET_BATMAN_ADV_LOG_H_
 19 #define _NET_BATMAN_ADV_LOG_H_
 20 
 21 #include "main.h"
 22 
 23 #include <linux/bitops.h>
 24 #include <linux/compiler.h>
 25 #include <linux/printk.h>
 26 
 27 #ifdef CONFIG_BATMAN_ADV_DEBUG
 28 
 29 int batadv_debug_log_setup(struct batadv_priv *bat_priv);
 30 void batadv_debug_log_cleanup(struct batadv_priv *bat_priv);
 31 
 32 #else
 33 
 34 static inline int batadv_debug_log_setup(struct batadv_priv *bat_priv)
 35 {
 36         return 0;
 37 }
 38 
 39 static inline void batadv_debug_log_cleanup(struct batadv_priv *bat_priv)
 40 {
 41 }
 42 
 43 #endif
 44 
 45 /**
 46  * enum batadv_dbg_level - available log levels
 47  * @BATADV_DBG_BATMAN: OGM and TQ computations related messages
 48  * @BATADV_DBG_ROUTES: route added / changed / deleted
 49  * @BATADV_DBG_TT: translation table messages
 50  * @BATADV_DBG_BLA: bridge loop avoidance messages
 51  * @BATADV_DBG_DAT: ARP snooping and DAT related messages
 52  * @BATADV_DBG_NC: network coding related messages
 53  * @BATADV_DBG_MCAST: multicast related messages
 54  * @BATADV_DBG_TP_METER: throughput meter messages
 55  * @BATADV_DBG_ALL: the union of all the above log levels
 56  */
 57 enum batadv_dbg_level {
 58         BATADV_DBG_BATMAN       = BIT(0),
 59         BATADV_DBG_ROUTES       = BIT(1),
 60         BATADV_DBG_TT           = BIT(2),
 61         BATADV_DBG_BLA          = BIT(3),
 62         BATADV_DBG_DAT          = BIT(4),
 63         BATADV_DBG_NC           = BIT(5),
 64         BATADV_DBG_MCAST        = BIT(6),
 65         BATADV_DBG_TP_METER     = BIT(7),
 66         BATADV_DBG_ALL          = 255,
 67 };
 68 
 69 #ifdef CONFIG_BATMAN_ADV_DEBUG
 70 int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
 71 __printf(2, 3);
 72 
 73 /* possibly ratelimited debug output */
 74 #define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...)           \
 75         do {                                                            \
 76                 struct batadv_priv *__batpriv = (bat_priv);             \
 77                 if (atomic_read(&__batpriv->log_level) & (type) &&      \
 78                     (!(ratelimited) || net_ratelimit()))                \
 79                         batadv_debug_log(__batpriv, fmt, ## arg);       \
 80         }                                                               \
 81         while (0)
 82 #else /* !CONFIG_BATMAN_ADV_DEBUG */
 83 __printf(4, 5)
 84 static inline void _batadv_dbg(int type __always_unused,
 85                                struct batadv_priv *bat_priv __always_unused,
 86                                int ratelimited __always_unused,
 87                                const char *fmt __always_unused, ...)
 88 {
 89 }
 90 #endif
 91 
 92 #define batadv_dbg(type, bat_priv, arg...) \
 93         _batadv_dbg(type, bat_priv, 0, ## arg)
 94 #define batadv_dbg_ratelimited(type, bat_priv, arg...) \
 95         _batadv_dbg(type, bat_priv, 1, ## arg)
 96 
 97 #define batadv_info(net_dev, fmt, arg...)                               \
 98         do {                                                            \
 99                 struct net_device *_netdev = (net_dev);                 \
100                 struct batadv_priv *_batpriv = netdev_priv(_netdev);    \
101                 batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg);      \
102                 pr_info("%s: " fmt, _netdev->name, ## arg);             \
103         } while (0)
104 #define batadv_err(net_dev, fmt, arg...)                                \
105         do {                                                            \
106                 struct net_device *_netdev = (net_dev);                 \
107                 struct batadv_priv *_batpriv = netdev_priv(_netdev);    \
108                 batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg);      \
109                 pr_err("%s: " fmt, _netdev->name, ## arg);              \
110         } while (0)
111 
112 #endif /* _NET_BATMAN_ADV_LOG_H_ */
113 

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp