datapath: Per cpu flow stats.
[sliver-openvswitch.git] / datapath / flow.h
index 91a3022..d1ac85a 100644 (file)
@@ -19,6 +19,7 @@
 #ifndef FLOW_H
 #define FLOW_H 1
 
+#include <linux/cache.h>
 #include <linux/kernel.h>
 #include <linux/netlink.h>
 #include <linux/openvswitch.h>
@@ -146,6 +147,14 @@ struct sw_flow_actions {
        struct nlattr actions[];
 };
 
+struct sw_flow_stats {
+       u64 packet_count;               /* Number of packets matched. */
+       u64 byte_count;                 /* Number of bytes matched. */
+       unsigned long used;             /* Last used time (in jiffies). */
+       spinlock_t lock;                /* Lock for atomic stats update. */
+       u8 tcp_flags;                   /* Union of seen TCP flags. */
+} ____cacheline_aligned_in_smp;
+
 struct sw_flow {
        struct rcu_head rcu;
        struct hlist_node hash_node[2];
@@ -155,12 +164,7 @@ struct sw_flow {
        struct sw_flow_key unmasked_key;
        struct sw_flow_mask *mask;
        struct sw_flow_actions __rcu *sf_acts;
-
-       spinlock_t lock;        /* Lock for values below. */
-       unsigned long used;     /* Last used time (in jiffies). */
-       u64 packet_count;       /* Number of packets matched. */
-       u64 byte_count;         /* Number of bytes matched. */
-       u8 tcp_flags;           /* Union of seen TCP flags. */
+       struct sw_flow_stats stats[];
 };
 
 struct arp_eth_header {
@@ -177,7 +181,9 @@ struct arp_eth_header {
        unsigned char       ar_tip[4];          /* target IP address        */
 } __packed;
 
-void ovs_flow_used(struct sw_flow *, struct sk_buff *);
+void ovs_flow_stats_update(struct sw_flow *flow, struct sk_buff *skb);
+void ovs_flow_stats_get(struct sw_flow *flow, struct sw_flow_stats *res);
+void ovs_flow_stats_clear(struct sw_flow *flow);
 u64 ovs_flow_used_time(unsigned long flow_jiffies);
 
 int ovs_flow_extract(struct sk_buff *, u16 in_port, struct sw_flow_key *);