diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-11-10 16:14:04 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-11-16 13:58:30 -0500 |
commit | 8ffab51b3dfc54876f145f15b351c41f3f703195 (patch) | |
tree | 0455321fbdb953e77fecff62345f8414553bc394 /include/linux/if_macvlan.h | |
parent | 0e3125c755445664f00ad036e4fc2cd32fd52877 (diff) |
macvlan: lockless tx path
macvlan is a stacked device, like tunnels. We should use the lockless
mechanism we are using in tunnels and loopback.
This patch completely removes locking in TX path.
tx stat counters are added into existing percpu stat structure, renamed
from rx_stats to pcpu_stats.
Note : this reverts commit 2c11455321f37 (macvlan: add multiqueue
capability)
Note : rx_errors converted to a 32bit counter, like tx_dropped, since
they dont need 64bit range.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Patrick McHardy <kaber@trash.net>
Cc: Ben Greear <greearb@candelatech.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
Acked-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/if_macvlan.h')
-rw-r--r-- | include/linux/if_macvlan.h | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/include/linux/if_macvlan.h b/include/linux/if_macvlan.h index ac96a2d76291..e28b2e4959d4 100644 --- a/include/linux/if_macvlan.h +++ b/include/linux/if_macvlan.h | |||
@@ -25,19 +25,25 @@ struct macvlan_port; | |||
25 | struct macvtap_queue; | 25 | struct macvtap_queue; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * struct macvlan_rx_stats - MACVLAN percpu rx stats | 28 | * struct macvlan_pcpu_stats - MACVLAN percpu stats |
29 | * @rx_packets: number of received packets | 29 | * @rx_packets: number of received packets |
30 | * @rx_bytes: number of received bytes | 30 | * @rx_bytes: number of received bytes |
31 | * @rx_multicast: number of received multicast packets | 31 | * @rx_multicast: number of received multicast packets |
32 | * @tx_packets: number of transmitted packets | ||
33 | * @tx_bytes: number of transmitted bytes | ||
32 | * @syncp: synchronization point for 64bit counters | 34 | * @syncp: synchronization point for 64bit counters |
33 | * @rx_errors: number of errors | 35 | * @rx_errors: number of rx errors |
36 | * @tx_dropped: number of tx dropped packets | ||
34 | */ | 37 | */ |
35 | struct macvlan_rx_stats { | 38 | struct macvlan_pcpu_stats { |
36 | u64 rx_packets; | 39 | u64 rx_packets; |
37 | u64 rx_bytes; | 40 | u64 rx_bytes; |
38 | u64 rx_multicast; | 41 | u64 rx_multicast; |
42 | u64 tx_packets; | ||
43 | u64 tx_bytes; | ||
39 | struct u64_stats_sync syncp; | 44 | struct u64_stats_sync syncp; |
40 | unsigned long rx_errors; | 45 | u32 rx_errors; |
46 | u32 tx_dropped; | ||
41 | }; | 47 | }; |
42 | 48 | ||
43 | /* | 49 | /* |
@@ -52,7 +58,7 @@ struct macvlan_dev { | |||
52 | struct hlist_node hlist; | 58 | struct hlist_node hlist; |
53 | struct macvlan_port *port; | 59 | struct macvlan_port *port; |
54 | struct net_device *lowerdev; | 60 | struct net_device *lowerdev; |
55 | struct macvlan_rx_stats __percpu *rx_stats; | 61 | struct macvlan_pcpu_stats __percpu *pcpu_stats; |
56 | enum macvlan_mode mode; | 62 | enum macvlan_mode mode; |
57 | int (*receive)(struct sk_buff *skb); | 63 | int (*receive)(struct sk_buff *skb); |
58 | int (*forward)(struct net_device *dev, struct sk_buff *skb); | 64 | int (*forward)(struct net_device *dev, struct sk_buff *skb); |
@@ -64,18 +70,18 @@ static inline void macvlan_count_rx(const struct macvlan_dev *vlan, | |||
64 | unsigned int len, bool success, | 70 | unsigned int len, bool success, |
65 | bool multicast) | 71 | bool multicast) |
66 | { | 72 | { |
67 | struct macvlan_rx_stats *rx_stats; | ||
68 | |||
69 | rx_stats = this_cpu_ptr(vlan->rx_stats); | ||
70 | if (likely(success)) { | 73 | if (likely(success)) { |
71 | u64_stats_update_begin(&rx_stats->syncp); | 74 | struct macvlan_pcpu_stats *pcpu_stats; |
72 | rx_stats->rx_packets++; | 75 | |
73 | rx_stats->rx_bytes += len; | 76 | pcpu_stats = this_cpu_ptr(vlan->pcpu_stats); |
77 | u64_stats_update_begin(&pcpu_stats->syncp); | ||
78 | pcpu_stats->rx_packets++; | ||
79 | pcpu_stats->rx_bytes += len; | ||
74 | if (multicast) | 80 | if (multicast) |
75 | rx_stats->rx_multicast++; | 81 | pcpu_stats->rx_multicast++; |
76 | u64_stats_update_end(&rx_stats->syncp); | 82 | u64_stats_update_end(&pcpu_stats->syncp); |
77 | } else { | 83 | } else { |
78 | rx_stats->rx_errors++; | 84 | this_cpu_inc(vlan->pcpu_stats->rx_errors); |
79 | } | 85 | } |
80 | } | 86 | } |
81 | 87 | ||