mirror of
https://git.openwrt.org/feed/routing.git
synced 2024-06-18 05:03:57 +02:00
batman-adv: add missing ewma compat declaration
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
This commit is contained in:
parent
06844bbcb7
commit
d5b83e53c5
|
@ -36,6 +36,47 @@
|
||||||
|
|
||||||
#define IFF_NO_QUEUE 0; dev->tx_queue_len = 0
|
#define IFF_NO_QUEUE 0; dev->tx_queue_len = 0
|
||||||
|
|
||||||
|
/* Exponentially weighted moving average (EWMA) */
|
||||||
|
|
||||||
|
#define DECLARE_EWMA(name, _factor, _weight) \
|
||||||
|
struct ewma_##name { \
|
||||||
|
unsigned long internal; \
|
||||||
|
}; \
|
||||||
|
static inline void ewma_##name##_init(struct ewma_##name *e) \
|
||||||
|
{ \
|
||||||
|
BUILD_BUG_ON(!__builtin_constant_p(_factor)); \
|
||||||
|
BUILD_BUG_ON(!__builtin_constant_p(_weight)); \
|
||||||
|
BUILD_BUG_ON_NOT_POWER_OF_2(_factor); \
|
||||||
|
BUILD_BUG_ON_NOT_POWER_OF_2(_weight); \
|
||||||
|
e->internal = 0; \
|
||||||
|
} \
|
||||||
|
static inline unsigned long \
|
||||||
|
ewma_##name##_read(struct ewma_##name *e) \
|
||||||
|
{ \
|
||||||
|
BUILD_BUG_ON(!__builtin_constant_p(_factor)); \
|
||||||
|
BUILD_BUG_ON(!__builtin_constant_p(_weight)); \
|
||||||
|
BUILD_BUG_ON_NOT_POWER_OF_2(_factor); \
|
||||||
|
BUILD_BUG_ON_NOT_POWER_OF_2(_weight); \
|
||||||
|
return e->internal >> ilog2(_factor); \
|
||||||
|
} \
|
||||||
|
static inline void ewma_##name##_add(struct ewma_##name *e, \
|
||||||
|
unsigned long val) \
|
||||||
|
{ \
|
||||||
|
unsigned long internal = ACCESS_ONCE(e->internal); \
|
||||||
|
unsigned long weight = ilog2(_weight); \
|
||||||
|
unsigned long factor = ilog2(_factor); \
|
||||||
|
\
|
||||||
|
BUILD_BUG_ON(!__builtin_constant_p(_factor)); \
|
||||||
|
BUILD_BUG_ON(!__builtin_constant_p(_weight)); \
|
||||||
|
BUILD_BUG_ON_NOT_POWER_OF_2(_factor); \
|
||||||
|
BUILD_BUG_ON_NOT_POWER_OF_2(_weight); \
|
||||||
|
\
|
||||||
|
ACCESS_ONCE(e->internal) = internal ? \
|
||||||
|
(((internal << weight) - internal) + \
|
||||||
|
(val << factor)) >> weight : \
|
||||||
|
(val << factor); \
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* < KERNEL_VERSION(4, 3, 0) */
|
#endif /* < KERNEL_VERSION(4, 3, 0) */
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user