2 * Copyright (c) 2009, 2010 Nicira Networks.
3 * Distributed under the terms of the GNU GPL version 2.
5 * Significant portions of this file may be copied from parts of the Linux
6 * kernel, by Linus Torvalds and others.
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 #include <linux/if_ether.h>
18 #include <linux/jiffies.h>
19 #include <linux/time.h>
21 #include "openvswitch/datapath-protocol.h"
26 struct sw_flow_actions {
28 unsigned int n_actions;
29 union odp_action actions[];
34 struct tbl_node tbl_node;
36 struct odp_flow_key key;
37 struct sw_flow_actions *sf_acts;
39 spinlock_t lock; /* Lock for values below. */
40 unsigned long used; /* Last used time (in jiffies). */
41 u64 packet_count; /* Number of packets matched. */
42 u64 byte_count; /* Number of bytes matched. */
43 u8 tcp_flags; /* Union of seen TCP flags. */
48 __be16 ar_hrd; /* format of hardware address */
49 __be16 ar_pro; /* format of protocol address */
50 unsigned char ar_hln; /* length of hardware address */
51 unsigned char ar_pln; /* length of protocol address */
52 __be16 ar_op; /* ARP opcode (command) */
54 /* Ethernet+IPv4 specific members. */
55 unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */
56 unsigned char ar_sip[4]; /* sender IP address */
57 unsigned char ar_tha[ETH_ALEN]; /* target hardware address */
58 unsigned char ar_tip[4]; /* target IP address */
59 } __attribute__((packed));
61 extern struct kmem_cache *flow_cache;
63 struct sw_flow_actions *flow_actions_alloc(size_t n_actions);
64 void flow_deferred_free(struct sw_flow *);
65 void flow_deferred_free_acts(struct sw_flow_actions *);
66 int flow_extract(struct sk_buff *, u16 in_port, struct odp_flow_key *);
67 void flow_used(struct sw_flow *, struct sk_buff *);
69 u32 flow_hash(const struct odp_flow_key *key);
70 int flow_cmp(const struct tbl_node *, void *target);
71 void flow_free_tbl(struct tbl_node *);
76 static inline struct sw_flow *flow_cast(const struct tbl_node *node)
78 return container_of(node, struct sw_flow, tbl_node);