Merge "master" branch into "db".
[sliver-openvswitch.git] / datapath / flow.h
1 /*
2  * Copyright (c) 2009 Nicira Networks.
3  * Distributed under the terms of the GNU GPL version 2.
4  *
5  * Significant portions of this file may be copied from parts of the Linux
6  * kernel, by Linus Torvalds and others.
7  */
8
9 #ifndef FLOW_H
10 #define FLOW_H 1
11
12 #include <linux/kernel.h>
13 #include <linux/spinlock.h>
14 #include <linux/types.h>
15 #include <linux/rcupdate.h>
16 #include <linux/gfp.h>
17
18 #include "openvswitch/datapath-protocol.h"
19
20 struct sk_buff;
21
22 struct sw_flow_actions {
23         struct rcu_head rcu;
24         unsigned int n_actions;
25         union odp_action actions[];
26 };
27
28 struct sw_flow {
29         struct rcu_head rcu;
30         struct odp_flow_key key;
31         struct sw_flow_actions *sf_acts;
32
33         struct timespec used;   /* Last used time. */
34
35         u8 ip_tos;              /* IP TOS value. */
36
37         spinlock_t lock;        /* Lock for values below. */
38         u64 packet_count;       /* Number of packets matched. */
39         u64 byte_count;         /* Number of bytes matched. */
40         u8 tcp_flags;           /* Union of seen TCP flags. */
41 };
42
43 extern struct kmem_cache *flow_cache;
44
45 struct sw_flow_actions *flow_actions_alloc(size_t n_actions);
46 void flow_free(struct sw_flow *);
47 void flow_deferred_free(struct sw_flow *);
48 void flow_deferred_free_acts(struct sw_flow_actions *);
49 int flow_extract(struct sk_buff *, u16 in_port, struct odp_flow_key *);
50 void flow_used(struct sw_flow *, struct sk_buff *);
51
52 int flow_init(void);
53 void flow_exit(void);
54
55 #endif /* flow.h */