2 * Copyright (c) 2007-2013 Nicira, Inc.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 2 of the GNU General Public
6 * License as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 #define FLOW_TABLE_H 1
22 #include <linux/kernel.h>
23 #include <linux/netlink.h>
24 #include <linux/openvswitch.h>
25 #include <linux/spinlock.h>
26 #include <linux/types.h>
27 #include <linux/rcupdate.h>
28 #include <linux/if_ether.h>
29 #include <linux/in6.h>
30 #include <linux/jiffies.h>
31 #include <linux/time.h>
32 #include <linux/flex_array.h>
34 #include <net/inet_ecn.h>
35 #include <net/ip_tunnels.h>
39 struct mask_cache_entry {
47 struct sw_flow_mask __rcu *masks[];
50 struct table_instance {
51 struct flex_array *buckets;
52 unsigned int n_buckets;
60 struct table_instance __rcu *ti;
61 struct table_instance __rcu *ufid_ti;
62 struct mask_cache_entry __percpu *mask_cache;
63 struct mask_array __rcu *mask_array;
64 unsigned long last_rehash;
66 unsigned int ufid_count;
69 extern struct kmem_cache *flow_stats_cache;
71 int ovs_flow_init(void);
72 void ovs_flow_exit(void);
74 struct sw_flow *ovs_flow_alloc(void);
75 void ovs_flow_free(struct sw_flow *, bool deferred);
77 int ovs_flow_tbl_init(struct flow_table *);
78 int ovs_flow_tbl_count(const struct flow_table *table);
79 void ovs_flow_tbl_destroy(struct flow_table *table);
80 int ovs_flow_tbl_flush(struct flow_table *flow_table);
82 int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow,
83 const struct sw_flow_mask *mask);
84 void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow);
85 int ovs_flow_tbl_num_masks(const struct flow_table *table);
86 struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table,
87 u32 *bucket, u32 *idx);
88 struct sw_flow *ovs_flow_tbl_lookup_stats(struct flow_table *,
89 const struct sw_flow_key *,
92 struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *,
93 const struct sw_flow_key *);
94 struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl,
95 const struct sw_flow_match *match);
96 struct sw_flow *ovs_flow_tbl_lookup_ufid(struct flow_table *,
97 const struct sw_flow_id *);
99 bool ovs_flow_cmp(const struct sw_flow *, const struct sw_flow_match *);
101 void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src,
102 bool full, const struct sw_flow_mask *mask);
103 #endif /* flow_table.h */