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

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

Version: ~ [ linux-6.3-rc3 ] ~ [ linux-6.2.7 ] ~ [ linux-6.1.20 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.103 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.175 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.237 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.278 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.310 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ 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) 2007-2019  B.A.T.M.A.N. contributors:
  3  *
  4  * Marek Lindner, Simon Wunderlich
  5  *
  6  * This program is free software; you can redistribute it and/or
  7  * modify it under the terms of version 2 of the GNU General Public
  8  * License as published by the Free Software Foundation.
  9  *
 10  * This program is distributed in the hope that it will be useful, but
 11  * WITHOUT ANY WARRANTY; without even the implied warranty of
 12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13  * General Public License for more details.
 14  *
 15  * You should have received a copy of the GNU General Public License
 16  * along with this program; if not, see <http://www.gnu.org/licenses/>.
 17  */
 18 
 19 #ifndef _NET_BATMAN_ADV_LOG_H_
 20 #define _NET_BATMAN_ADV_LOG_H_
 21 
 22 #include "main.h"
 23 
 24 #include <linux/bitops.h>
 25 #include <linux/compiler.h>
 26 #include <linux/printk.h>
 27 
 28 #ifdef CONFIG_BATMAN_ADV_DEBUG
 29 
 30 int batadv_debug_log_setup(struct batadv_priv *bat_priv);
 31 void batadv_debug_log_cleanup(struct batadv_priv *bat_priv);
 32 
 33 #else
 34 
 35 static inline int batadv_debug_log_setup(struct batadv_priv *bat_priv)
 36 {
 37         return 0;
 38 }
 39 
 40 static inline void batadv_debug_log_cleanup(struct batadv_priv *bat_priv)
 41 {
 42 }
 43 
 44 #endif
 45 
 46 /**
 47  * enum batadv_dbg_level - available log levels
 48  */
 49 enum batadv_dbg_level {
 50         /** @BATADV_DBG_BATMAN: OGM and TQ computations related messages */
 51         BATADV_DBG_BATMAN       = BIT(0),
 52 
 53         /** @BATADV_DBG_ROUTES: route added / changed / deleted */
 54         BATADV_DBG_ROUTES       = BIT(1),
 55 
 56         /** @BATADV_DBG_TT: translation table messages */
 57         BATADV_DBG_TT           = BIT(2),
 58 
 59         /** @BATADV_DBG_BLA: bridge loop avoidance messages */
 60         BATADV_DBG_BLA          = BIT(3),
 61 
 62         /** @BATADV_DBG_DAT: ARP snooping and DAT related messages */
 63         BATADV_DBG_DAT          = BIT(4),
 64 
 65         /** @BATADV_DBG_NC: network coding related messages */
 66         BATADV_DBG_NC           = BIT(5),
 67 
 68         /** @BATADV_DBG_MCAST: multicast related messages */
 69         BATADV_DBG_MCAST        = BIT(6),
 70 
 71         /** @BATADV_DBG_TP_METER: throughput meter messages */
 72         BATADV_DBG_TP_METER     = BIT(7),
 73 
 74         /** @BATADV_DBG_ALL: the union of all the above log levels */
 75         BATADV_DBG_ALL          = 255,
 76 };
 77 
 78 #ifdef CONFIG_BATMAN_ADV_DEBUG
 79 int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
 80 __printf(2, 3);
 81 
 82 /**
 83  * _batadv_dbg() - Store debug output with(out) ratelimiting
 84  * @type: type of debug message
 85  * @bat_priv: the bat priv with all the soft interface information
 86  * @ratelimited: whether output should be rate limited
 87  * @fmt: format string
 88  * @arg...: variable arguments
 89  */
 90 #define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...)           \
 91         do {                                                            \
 92                 struct batadv_priv *__batpriv = (bat_priv);             \
 93                 if (atomic_read(&__batpriv->log_level) & (type) &&      \
 94                     (!(ratelimited) || net_ratelimit()))                \
 95                         batadv_debug_log(__batpriv, fmt, ## arg);       \
 96         }                                                               \
 97         while (0)
 98 #else /* !CONFIG_BATMAN_ADV_DEBUG */
 99 __printf(4, 5)
100 static inline void _batadv_dbg(int type __always_unused,
101                                struct batadv_priv *bat_priv __always_unused,
102                                int ratelimited __always_unused,
103                                const char *fmt __always_unused, ...)
104 {
105 }
106 #endif
107 
108 /**
109  * batadv_dbg() - Store debug output without ratelimiting
110  * @type: type of debug message
111  * @bat_priv: the bat priv with all the soft interface information
112  * @arg...: format string and variable arguments
113  */
114 #define batadv_dbg(type, bat_priv, arg...) \
115         _batadv_dbg(type, bat_priv, 0, ## arg)
116 
117 /**
118  * batadv_dbg_ratelimited() - Store debug output with ratelimiting
119  * @type: type of debug message
120  * @bat_priv: the bat priv with all the soft interface information
121  * @arg...: format string and variable arguments
122  */
123 #define batadv_dbg_ratelimited(type, bat_priv, arg...) \
124         _batadv_dbg(type, bat_priv, 1, ## arg)
125 
126 /**
127  * batadv_info() - Store message in debug buffer and print it to kmsg buffer
128  * @net_dev: the soft interface net device
129  * @fmt: format string
130  * @arg...: variable arguments
131  */
132 #define batadv_info(net_dev, fmt, arg...)                               \
133         do {                                                            \
134                 struct net_device *_netdev = (net_dev);                 \
135                 struct batadv_priv *_batpriv = netdev_priv(_netdev);    \
136                 batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg);      \
137                 pr_info("%s: " fmt, _netdev->name, ## arg);             \
138         } while (0)
139 
140 /**
141  * batadv_err() - Store error in debug buffer and print it to kmsg buffer
142  * @net_dev: the soft interface net device
143  * @fmt: format string
144  * @arg...: variable arguments
145  */
146 #define batadv_err(net_dev, fmt, arg...)                                \
147         do {                                                            \
148                 struct net_device *_netdev = (net_dev);                 \
149                 struct batadv_priv *_batpriv = netdev_priv(_netdev);    \
150                 batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg);      \
151                 pr_err("%s: " fmt, _netdev->name, ## arg);              \
152         } while (0)
153 
154 #endif /* _NET_BATMAN_ADV_LOG_H_ */
155 

~ [ 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