Pravin B Shelar | e644571 | 2013-10-03 18:16:47 -0700 | [diff] [blame] | 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> |
Pravin B Shelar | e644571 | 2013-10-03 18:16:47 -0700 | [diff] [blame] | 32 | |
| 33 | #include <net/inet_ecn.h> |
| 34 | #include <net/ip_tunnels.h> |
| 35 | |
| 36 | #include "flow.h" |
| 37 | |
Pravin B Shelar | b637e49 | 2013-10-04 00:14:23 -0700 | [diff] [blame] | 38 | struct table_instance { |
Kent Overstreet | ee9c5e6 | 2019-03-11 23:31:02 -0700 | [diff] [blame] | 39 | struct hlist_head *buckets; |
Pravin B Shelar | b637e49 | 2013-10-04 00:14:23 -0700 | [diff] [blame] | 40 | unsigned int n_buckets; |
Pravin B Shelar | e644571 | 2013-10-03 18:16:47 -0700 | [diff] [blame] | 41 | struct rcu_head rcu; |
Pravin B Shelar | e644571 | 2013-10-03 18:16:47 -0700 | [diff] [blame] | 42 | int node_ver; |
| 43 | u32 hash_seed; |
| 44 | bool keep_flows; |
| 45 | }; |
| 46 | |
Pravin B Shelar | b637e49 | 2013-10-04 00:14:23 -0700 | [diff] [blame] | 47 | struct flow_table { |
| 48 | struct table_instance __rcu *ti; |
Joe Stringer | 74ed7ab | 2015-01-21 16:42:52 -0800 | [diff] [blame] | 49 | struct table_instance __rcu *ufid_ti; |
Pravin B Shelar | b637e49 | 2013-10-04 00:14:23 -0700 | [diff] [blame] | 50 | struct list_head mask_list; |
| 51 | unsigned long last_rehash; |
| 52 | unsigned int count; |
Joe Stringer | 74ed7ab | 2015-01-21 16:42:52 -0800 | [diff] [blame] | 53 | unsigned int ufid_count; |
Pravin B Shelar | b637e49 | 2013-10-04 00:14:23 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
Jarno Rajahalme | 63e7959 | 2014-03-27 12:42:54 -0700 | [diff] [blame] | 56 | extern struct kmem_cache *flow_stats_cache; |
| 57 | |
Pravin B Shelar | e644571 | 2013-10-03 18:16:47 -0700 | [diff] [blame] | 58 | int ovs_flow_init(void); |
| 59 | void ovs_flow_exit(void); |
| 60 | |
Jarno Rajahalme | 23dabf8 | 2014-03-27 12:35:23 -0700 | [diff] [blame] | 61 | struct sw_flow *ovs_flow_alloc(void); |
Pravin B Shelar | e644571 | 2013-10-03 18:16:47 -0700 | [diff] [blame] | 62 | void ovs_flow_free(struct sw_flow *, bool deferred); |
| 63 | |
Pravin B Shelar | b637e49 | 2013-10-04 00:14:23 -0700 | [diff] [blame] | 64 | int ovs_flow_tbl_init(struct flow_table *); |
Thomas Graf | 12eb18f | 2014-11-06 06:58:52 -0800 | [diff] [blame] | 65 | int ovs_flow_tbl_count(const struct flow_table *table); |
Pravin B Shelar | 9b996e5 | 2014-05-06 18:41:20 -0700 | [diff] [blame] | 66 | void ovs_flow_tbl_destroy(struct flow_table *table); |
Pravin B Shelar | b637e49 | 2013-10-04 00:14:23 -0700 | [diff] [blame] | 67 | int ovs_flow_tbl_flush(struct flow_table *flow_table); |
Pravin B Shelar | e644571 | 2013-10-03 18:16:47 -0700 | [diff] [blame] | 68 | |
Pravin B Shelar | 618ed0c | 2013-10-04 00:17:42 -0700 | [diff] [blame] | 69 | int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow, |
Thomas Graf | 12eb18f | 2014-11-06 06:58:52 -0800 | [diff] [blame] | 70 | const struct sw_flow_mask *mask); |
Pravin B Shelar | e644571 | 2013-10-03 18:16:47 -0700 | [diff] [blame] | 71 | void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow); |
Andy Zhou | 1bd7116 | 2013-10-22 10:42:46 -0700 | [diff] [blame] | 72 | int ovs_flow_tbl_num_masks(const struct flow_table *table); |
Pravin B Shelar | b637e49 | 2013-10-04 00:14:23 -0700 | [diff] [blame] | 73 | struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table, |
Pravin B Shelar | e644571 | 2013-10-03 18:16:47 -0700 | [diff] [blame] | 74 | u32 *bucket, u32 *idx); |
Andy Zhou | 5bb5063 | 2013-11-25 10:42:46 -0800 | [diff] [blame] | 75 | struct sw_flow *ovs_flow_tbl_lookup_stats(struct flow_table *, |
Andy Zhou | 1bd7116 | 2013-10-22 10:42:46 -0700 | [diff] [blame] | 76 | const struct sw_flow_key *, |
| 77 | u32 *n_mask_hit); |
Andy Zhou | 5bb5063 | 2013-11-25 10:42:46 -0800 | [diff] [blame] | 78 | struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *, |
| 79 | const struct sw_flow_key *); |
Alex Wang | 4a46b24 | 2014-06-30 20:30:29 -0700 | [diff] [blame] | 80 | struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl, |
Thomas Graf | 12eb18f | 2014-11-06 06:58:52 -0800 | [diff] [blame] | 81 | const struct sw_flow_match *match); |
Joe Stringer | 74ed7ab | 2015-01-21 16:42:52 -0800 | [diff] [blame] | 82 | struct sw_flow *ovs_flow_tbl_lookup_ufid(struct flow_table *, |
| 83 | const struct sw_flow_id *); |
| 84 | |
| 85 | bool ovs_flow_cmp(const struct sw_flow *, const struct sw_flow_match *); |
Pravin B Shelar | e644571 | 2013-10-03 18:16:47 -0700 | [diff] [blame] | 86 | |
Pravin B Shelar | e644571 | 2013-10-03 18:16:47 -0700 | [diff] [blame] | 87 | void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src, |
Jesse Gross | ae5f2fb | 2015-09-21 20:21:20 -0700 | [diff] [blame] | 88 | bool full, const struct sw_flow_mask *mask); |
Pravin B Shelar | e644571 | 2013-10-03 18:16:47 -0700 | [diff] [blame] | 89 | #endif /* flow_table.h */ |