Commit | Line | Data |
---|---|---|
e6445719 PS |
1 | /* |
2 | * Copyright (c) 2007-2013 Nicira, Inc. | |
3 | * | |
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. | |
7 | * | |
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. | |
12 | * | |
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 | |
16 | * 02110-1301, USA | |
17 | */ | |
18 | ||
19 | #ifndef FLOW_TABLE_H | |
20 | #define FLOW_TABLE_H 1 | |
21 | ||
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> | |
33 | ||
34 | #include <net/inet_ecn.h> | |
35 | #include <net/ip_tunnels.h> | |
36 | ||
37 | #include "flow.h" | |
38 | ||
b637e498 | 39 | struct table_instance { |
e6445719 | 40 | struct flex_array *buckets; |
b637e498 | 41 | unsigned int n_buckets; |
e6445719 | 42 | struct rcu_head rcu; |
e6445719 PS |
43 | int node_ver; |
44 | u32 hash_seed; | |
45 | bool keep_flows; | |
46 | }; | |
47 | ||
b637e498 PS |
48 | struct flow_table { |
49 | struct table_instance __rcu *ti; | |
50 | struct list_head mask_list; | |
51 | unsigned long last_rehash; | |
52 | unsigned int count; | |
53 | }; | |
54 | ||
63e7959c JR |
55 | extern struct kmem_cache *flow_stats_cache; |
56 | ||
e6445719 PS |
57 | int ovs_flow_init(void); |
58 | void ovs_flow_exit(void); | |
59 | ||
23dabf88 | 60 | struct sw_flow *ovs_flow_alloc(void); |
e6445719 PS |
61 | void ovs_flow_free(struct sw_flow *, bool deferred); |
62 | ||
b637e498 | 63 | int ovs_flow_tbl_init(struct flow_table *); |
12eb18f7 | 64 | int ovs_flow_tbl_count(const struct flow_table *table); |
9b996e54 | 65 | void ovs_flow_tbl_destroy(struct flow_table *table); |
b637e498 | 66 | int ovs_flow_tbl_flush(struct flow_table *flow_table); |
e6445719 | 67 | |
618ed0c8 | 68 | int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow, |
12eb18f7 | 69 | const struct sw_flow_mask *mask); |
e6445719 | 70 | void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow); |
1bd7116f | 71 | int ovs_flow_tbl_num_masks(const struct flow_table *table); |
b637e498 | 72 | struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table, |
e6445719 | 73 | u32 *bucket, u32 *idx); |
5bb50632 | 74 | struct sw_flow *ovs_flow_tbl_lookup_stats(struct flow_table *, |
1bd7116f AZ |
75 | const struct sw_flow_key *, |
76 | u32 *n_mask_hit); | |
5bb50632 AZ |
77 | struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *, |
78 | const struct sw_flow_key *); | |
4a46b24e | 79 | struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl, |
12eb18f7 | 80 | const struct sw_flow_match *match); |
e6445719 | 81 | bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow, |
12eb18f7 | 82 | const struct sw_flow_match *match); |
e6445719 | 83 | |
e6445719 PS |
84 | void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src, |
85 | const struct sw_flow_mask *mask); | |
e6445719 | 86 | #endif /* flow_table.h */ |