55efede1b885bcda48c3abc57eda91bf3858786f
[cascardo/ovs.git] / datapath / flow.h
1 #ifndef FLOW_H
2 #define FLOW_H 1
3
4 #include <linux/kernel.h>
5 #include <linux/spinlock.h>
6 #include <linux/types.h>
7 #include <linux/rcupdate.h>
8 #include <linux/gfp.h>
9
10 #include "openvswitch/datapath-protocol.h"
11
12 struct sk_buff;
13
14 struct sw_flow_actions {
15         struct rcu_head rcu;
16         unsigned int n_actions;
17         union odp_action actions[];
18 };
19
20 struct sw_flow {
21         struct rcu_head rcu;
22         struct odp_flow_key key;
23         struct sw_flow_actions *sf_acts;
24
25         struct timespec used;   /* Last used time. */
26
27         u8 ip_tos;              /* IP TOS value. */
28
29         spinlock_t lock;        /* Lock for values below. */
30         u64 packet_count;       /* Number of packets matched. */
31         u64 byte_count;         /* Number of bytes matched. */
32         u8 tcp_flags;           /* Union of seen TCP flags. */
33 };
34
35 extern struct kmem_cache *flow_cache;
36
37 struct sw_flow_actions *flow_actions_alloc(size_t n_actions);
38 void flow_free(struct sw_flow *);
39 void flow_deferred_free(struct sw_flow *);
40 void flow_deferred_free_acts(struct sw_flow_actions *);
41 int flow_extract(struct sk_buff *, u16 in_port, struct odp_flow_key *);
42 void flow_used(struct sw_flow *, struct sk_buff *);
43
44 void print_flow(const struct odp_flow_key *);
45
46 int flow_init(void);
47 void flow_exit(void);
48
49 #endif /* flow.h */