aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-03-04 20:31:39 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-03-04 20:31:39 -0500
commit8d70eeb84ab277377c017af6a21d0a337025dede (patch)
treed6e8a80e1d5e953ab37eef0c7468c77e7735779b /include/linux
parent2d62e0768d3c28536d4cfe4c40ba1e5e8e442a93 (diff)
parentf78ef7cd9a0686b979679d0de061c6dbfd8d649e (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Fix double-free in batman-adv, from Sven Eckelmann. 2) Fix packet stats for fast-RX path, from Joannes Berg. 3) Netfilter's ip_route_me_harder() doesn't handle request sockets properly, fix from Florian Westphal. 4) Fix sendmsg deadlock in rxrpc, from David Howells. 5) Add missing RCU locking to transport hashtable scan, from Xin Long. 6) Fix potential packet loss in mlxsw driver, from Ido Schimmel. 7) Fix race in NAPI handling between poll handlers and busy polling, from Eric Dumazet. 8) TX path in vxlan and geneve need proper RCU locking, from Jakub Kicinski. 9) SYN processing in DCCP and TCP need to disable BH, from Eric Dumazet. 10) Properly handle net_enable_timestamp() being invoked from IRQ context, also from Eric Dumazet. 11) Fix crash on device-tree systems in xgene driver, from Alban Bedel. 12) Do not call sk_free() on a locked socket, from Arnaldo Carvalho de Melo. 13) Fix use-after-free in netvsc driver, from Dexuan Cui. 14) Fix max MTU setting in bonding driver, from WANG Cong. 15) xen-netback hash table can be allocated from softirq context, so use GFP_ATOMIC. From Anoob Soman. 16) Fix MAC address change bug in bgmac driver, from Hari Vyas. 17) strparser needs to destroy strp_wq on module exit, from WANG Cong. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (69 commits) strparser: destroy workqueue on module exit sfc: fix IPID endianness in TSOv2 sfc: avoid max() in array size rds: remove unnecessary returned value check rxrpc: Fix potential NULL-pointer exception nfp: correct DMA direction in XDP DMA sync nfp: don't tell FW about the reserved buffer space net: ethernet: bgmac: mac address change bug net: ethernet: bgmac: init sequence bug xen-netback: don't vfree() queues under spinlock xen-netback: keep a local pointer for vif in backend_disconnect() netfilter: nf_tables: don't call nfnetlink_set_err() if nfnetlink_send() fails netfilter: nft_set_rbtree: incorrect assumption on lower interval lookups netfilter: nf_conntrack_sip: fix wrong memory initialisation can: flexcan: fix typo in comment can: usb_8dev: Fix memory leak of priv->cmd_msg_buffer can: gs_usb: fix coding style can: gs_usb: Don't use stack memory for USB transfers ixgbe: Limit use of 2K buffers on architectures with 256B or larger cache lines ixgbe: update the rss key on h/w, when ethtool ask for it ...
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/average.h61
-rw-r--r--include/linux/mlx4/driver.h2
-rw-r--r--include/linux/netdevice.h29
3 files changed, 51 insertions, 41 deletions
diff --git a/include/linux/average.h b/include/linux/average.h
index d04aa58280de..7ddaf340d2ac 100644
--- a/include/linux/average.h
+++ b/include/linux/average.h
@@ -1,45 +1,66 @@
1#ifndef _LINUX_AVERAGE_H 1#ifndef _LINUX_AVERAGE_H
2#define _LINUX_AVERAGE_H 2#define _LINUX_AVERAGE_H
3 3
4/* Exponentially weighted moving average (EWMA) */ 4/*
5 * Exponentially weighted moving average (EWMA)
6 *
7 * This implements a fixed-precision EWMA algorithm, with both the
8 * precision and fall-off coefficient determined at compile-time
9 * and built into the generated helper funtions.
10 *
11 * The first argument to the macro is the name that will be used
12 * for the struct and helper functions.
13 *
14 * The second argument, the precision, expresses how many bits are
15 * used for the fractional part of the fixed-precision values.
16 *
17 * The third argument, the weight reciprocal, determines how the
18 * new values will be weighed vs. the old state, new values will
19 * get weight 1/weight_rcp and old values 1-1/weight_rcp. Note
20 * that this parameter must be a power of two for efficiency.
21 */
5 22
6#define DECLARE_EWMA(name, _factor, _weight) \ 23#define DECLARE_EWMA(name, _precision, _weight_rcp) \
7 struct ewma_##name { \ 24 struct ewma_##name { \
8 unsigned long internal; \ 25 unsigned long internal; \
9 }; \ 26 }; \
10 static inline void ewma_##name##_init(struct ewma_##name *e) \ 27 static inline void ewma_##name##_init(struct ewma_##name *e) \
11 { \ 28 { \
12 BUILD_BUG_ON(!__builtin_constant_p(_factor)); \ 29 BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
13 BUILD_BUG_ON(!__builtin_constant_p(_weight)); \ 30 BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
14 BUILD_BUG_ON_NOT_POWER_OF_2(_factor); \ 31 /* \
15 BUILD_BUG_ON_NOT_POWER_OF_2(_weight); \ 32 * Even if you want to feed it just 0/1 you should have \
33 * some bits for the non-fractional part... \
34 */ \
35 BUILD_BUG_ON((_precision) > 30); \
36 BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
16 e->internal = 0; \ 37 e->internal = 0; \
17 } \ 38 } \
18 static inline unsigned long \ 39 static inline unsigned long \
19 ewma_##name##_read(struct ewma_##name *e) \ 40 ewma_##name##_read(struct ewma_##name *e) \
20 { \ 41 { \
21 BUILD_BUG_ON(!__builtin_constant_p(_factor)); \ 42 BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
22 BUILD_BUG_ON(!__builtin_constant_p(_weight)); \ 43 BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
23 BUILD_BUG_ON_NOT_POWER_OF_2(_factor); \ 44 BUILD_BUG_ON((_precision) > 30); \
24 BUILD_BUG_ON_NOT_POWER_OF_2(_weight); \ 45 BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
25 return e->internal >> ilog2(_factor); \ 46 return e->internal >> (_precision); \
26 } \ 47 } \
27 static inline void ewma_##name##_add(struct ewma_##name *e, \ 48 static inline void ewma_##name##_add(struct ewma_##name *e, \
28 unsigned long val) \ 49 unsigned long val) \
29 { \ 50 { \
30 unsigned long internal = ACCESS_ONCE(e->internal); \ 51 unsigned long internal = ACCESS_ONCE(e->internal); \
31 unsigned long weight = ilog2(_weight); \ 52 unsigned long weight_rcp = ilog2(_weight_rcp); \
32 unsigned long factor = ilog2(_factor); \ 53 unsigned long precision = _precision; \
33 \ 54 \
34 BUILD_BUG_ON(!__builtin_constant_p(_factor)); \ 55 BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
35 BUILD_BUG_ON(!__builtin_constant_p(_weight)); \ 56 BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
36 BUILD_BUG_ON_NOT_POWER_OF_2(_factor); \ 57 BUILD_BUG_ON((_precision) > 30); \
37 BUILD_BUG_ON_NOT_POWER_OF_2(_weight); \ 58 BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
38 \ 59 \
39 ACCESS_ONCE(e->internal) = internal ? \ 60 ACCESS_ONCE(e->internal) = internal ? \
40 (((internal << weight) - internal) + \ 61 (((internal << weight_rcp) - internal) + \
41 (val << factor)) >> weight : \ 62 (val << precision)) >> weight_rcp : \
42 (val << factor); \ 63 (val << precision); \
43 } 64 }
44 65
45#endif /* _LINUX_AVERAGE_H */ 66#endif /* _LINUX_AVERAGE_H */
diff --git a/include/linux/mlx4/driver.h b/include/linux/mlx4/driver.h
index e965e5090d96..a858bcb6220b 100644
--- a/include/linux/mlx4/driver.h
+++ b/include/linux/mlx4/driver.h
@@ -109,7 +109,7 @@ static inline void mlx4_u64_to_mac(u8 *addr, u64 mac)
109 int i; 109 int i;
110 110
111 for (i = ETH_ALEN; i > 0; i--) { 111 for (i = ETH_ALEN; i > 0; i--) {
112 addr[i - 1] = mac && 0xFF; 112 addr[i - 1] = mac & 0xFF;
113 mac >>= 8; 113 mac >>= 8;
114 } 114 }
115} 115}
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f40f0ab3847a..97456b2539e4 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -330,6 +330,7 @@ struct napi_struct {
330 330
331enum { 331enum {
332 NAPI_STATE_SCHED, /* Poll is scheduled */ 332 NAPI_STATE_SCHED, /* Poll is scheduled */
333 NAPI_STATE_MISSED, /* reschedule a napi */
333 NAPI_STATE_DISABLE, /* Disable pending */ 334 NAPI_STATE_DISABLE, /* Disable pending */
334 NAPI_STATE_NPSVC, /* Netpoll - don't dequeue from poll_list */ 335 NAPI_STATE_NPSVC, /* Netpoll - don't dequeue from poll_list */
335 NAPI_STATE_HASHED, /* In NAPI hash (busy polling possible) */ 336 NAPI_STATE_HASHED, /* In NAPI hash (busy polling possible) */
@@ -338,12 +339,13 @@ enum {
338}; 339};
339 340
340enum { 341enum {
341 NAPIF_STATE_SCHED = (1UL << NAPI_STATE_SCHED), 342 NAPIF_STATE_SCHED = BIT(NAPI_STATE_SCHED),
342 NAPIF_STATE_DISABLE = (1UL << NAPI_STATE_DISABLE), 343 NAPIF_STATE_MISSED = BIT(NAPI_STATE_MISSED),
343 NAPIF_STATE_NPSVC = (1UL << NAPI_STATE_NPSVC), 344 NAPIF_STATE_DISABLE = BIT(NAPI_STATE_DISABLE),
344 NAPIF_STATE_HASHED = (1UL << NAPI_STATE_HASHED), 345 NAPIF_STATE_NPSVC = BIT(NAPI_STATE_NPSVC),
345 NAPIF_STATE_NO_BUSY_POLL = (1UL << NAPI_STATE_NO_BUSY_POLL), 346 NAPIF_STATE_HASHED = BIT(NAPI_STATE_HASHED),
346 NAPIF_STATE_IN_BUSY_POLL = (1UL << NAPI_STATE_IN_BUSY_POLL), 347 NAPIF_STATE_NO_BUSY_POLL = BIT(NAPI_STATE_NO_BUSY_POLL),
348 NAPIF_STATE_IN_BUSY_POLL = BIT(NAPI_STATE_IN_BUSY_POLL),
347}; 349};
348 350
349enum gro_result { 351enum gro_result {
@@ -414,20 +416,7 @@ static inline bool napi_disable_pending(struct napi_struct *n)
414 return test_bit(NAPI_STATE_DISABLE, &n->state); 416 return test_bit(NAPI_STATE_DISABLE, &n->state);
415} 417}
416 418
417/** 419bool napi_schedule_prep(struct napi_struct *n);
418 * napi_schedule_prep - check if NAPI can be scheduled
419 * @n: NAPI context
420 *
421 * Test if NAPI routine is already running, and if not mark
422 * it as running. This is used as a condition variable to
423 * insure only one NAPI poll instance runs. We also make
424 * sure there is no pending NAPI disable.
425 */
426static inline bool napi_schedule_prep(struct napi_struct *n)
427{
428 return !napi_disable_pending(n) &&
429 !test_and_set_bit(NAPI_STATE_SCHED, &n->state);
430}
431 420
432/** 421/**
433 * napi_schedule - schedule NAPI poll 422 * napi_schedule - schedule NAPI poll