Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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