]>
Commit | Line | Data |
---|---|---|
a14bc59f | 1 | /* |
5153ef3d | 2 | * Copyright (c) 2009, 2010 Nicira Networks. |
a14bc59f BP |
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 | ||
064af421 BP |
9 | #ifndef FLOW_H |
10 | #define FLOW_H 1 | |
11 | ||
12 | #include <linux/kernel.h> | |
78d18dbb | 13 | #include <linux/netlink.h> |
064af421 BP |
14 | #include <linux/spinlock.h> |
15 | #include <linux/types.h> | |
16 | #include <linux/rcupdate.h> | |
401eeb92 | 17 | #include <linux/if_ether.h> |
6bfafa55 | 18 | #include <linux/jiffies.h> |
5153ef3d | 19 | #include <linux/time.h> |
064af421 BP |
20 | |
21 | #include "openvswitch/datapath-protocol.h" | |
8d5ebd83 | 22 | #include "table.h" |
064af421 BP |
23 | |
24 | struct sk_buff; | |
25 | ||
26 | struct sw_flow_actions { | |
27 | struct rcu_head rcu; | |
cdee00fd BP |
28 | u32 actions_len; |
29 | struct nlattr actions[]; | |
064af421 BP |
30 | }; |
31 | ||
32 | struct sw_flow { | |
33 | struct rcu_head rcu; | |
8d5ebd83 JG |
34 | struct tbl_node tbl_node; |
35 | ||
064af421 BP |
36 | struct odp_flow_key key; |
37 | struct sw_flow_actions *sf_acts; | |
38 | ||
fb8c9347 JG |
39 | atomic_t refcnt; |
40 | bool dead; | |
41 | ||
064af421 | 42 | spinlock_t lock; /* Lock for values below. */ |
6bfafa55 | 43 | unsigned long used; /* Last used time (in jiffies). */ |
064af421 BP |
44 | u64 packet_count; /* Number of packets matched. */ |
45 | u64 byte_count; /* Number of bytes matched. */ | |
46 | u8 tcp_flags; /* Union of seen TCP flags. */ | |
47 | }; | |
48 | ||
401eeb92 BP |
49 | struct arp_eth_header |
50 | { | |
51 | __be16 ar_hrd; /* format of hardware address */ | |
52 | __be16 ar_pro; /* format of protocol address */ | |
53 | unsigned char ar_hln; /* length of hardware address */ | |
54 | unsigned char ar_pln; /* length of protocol address */ | |
55 | __be16 ar_op; /* ARP opcode (command) */ | |
56 | ||
57 | /* Ethernet+IPv4 specific members. */ | |
58 | unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */ | |
59 | unsigned char ar_sip[4]; /* sender IP address */ | |
60 | unsigned char ar_tha[ETH_ALEN]; /* target hardware address */ | |
61 | unsigned char ar_tip[4]; /* target IP address */ | |
62 | } __attribute__((packed)); | |
63 | ||
560e8022 JG |
64 | int flow_init(void); |
65 | void flow_exit(void); | |
064af421 | 66 | |
560e8022 | 67 | struct sw_flow *flow_alloc(void); |
064af421 | 68 | void flow_deferred_free(struct sw_flow *); |
560e8022 JG |
69 | void flow_free_tbl(struct tbl_node *); |
70 | ||
cdee00fd | 71 | struct sw_flow_actions *flow_actions_alloc(u32 actions_len); |
064af421 | 72 | void flow_deferred_free_acts(struct sw_flow_actions *); |
560e8022 | 73 | |
fb8c9347 JG |
74 | void flow_hold(struct sw_flow *); |
75 | void flow_put(struct sw_flow *); | |
76 | ||
b7a31ec1 | 77 | int flow_extract(struct sk_buff *, u16 in_port, struct odp_flow_key *, bool *is_frag); |
064af421 BP |
78 | void flow_used(struct sw_flow *, struct sk_buff *); |
79 | ||
8d5ebd83 JG |
80 | u32 flow_hash(const struct odp_flow_key *key); |
81 | int flow_cmp(const struct tbl_node *, void *target); | |
064af421 | 82 | |
9d209493 BP |
83 | static inline struct sw_flow *flow_cast(const struct tbl_node *node) |
84 | { | |
85 | return container_of(node, struct sw_flow, tbl_node); | |
86 | } | |
87 | ||
064af421 | 88 | #endif /* flow.h */ |