1e6445719SPravin B Shelar /* 2e6445719SPravin B Shelar * Copyright (c) 2007-2013 Nicira, Inc. 3e6445719SPravin B Shelar * 4e6445719SPravin B Shelar * This program is free software; you can redistribute it and/or 5e6445719SPravin B Shelar * modify it under the terms of version 2 of the GNU General Public 6e6445719SPravin B Shelar * License as published by the Free Software Foundation. 7e6445719SPravin B Shelar * 8e6445719SPravin B Shelar * This program is distributed in the hope that it will be useful, but 9e6445719SPravin B Shelar * WITHOUT ANY WARRANTY; without even the implied warranty of 10e6445719SPravin B Shelar * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11e6445719SPravin B Shelar * General Public License for more details. 12e6445719SPravin B Shelar * 13e6445719SPravin B Shelar * You should have received a copy of the GNU General Public License 14e6445719SPravin B Shelar * along with this program; if not, write to the Free Software 15e6445719SPravin B Shelar * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16e6445719SPravin B Shelar * 02110-1301, USA 17e6445719SPravin B Shelar */ 18e6445719SPravin B Shelar 19e6445719SPravin B Shelar #ifndef FLOW_TABLE_H 20e6445719SPravin B Shelar #define FLOW_TABLE_H 1 21e6445719SPravin B Shelar 22e6445719SPravin B Shelar #include <linux/kernel.h> 23e6445719SPravin B Shelar #include <linux/netlink.h> 24e6445719SPravin B Shelar #include <linux/openvswitch.h> 25e6445719SPravin B Shelar #include <linux/spinlock.h> 26e6445719SPravin B Shelar #include <linux/types.h> 27e6445719SPravin B Shelar #include <linux/rcupdate.h> 28e6445719SPravin B Shelar #include <linux/if_ether.h> 29e6445719SPravin B Shelar #include <linux/in6.h> 30e6445719SPravin B Shelar #include <linux/jiffies.h> 31e6445719SPravin B Shelar #include <linux/time.h> 32e6445719SPravin B Shelar 33e6445719SPravin B Shelar #include <net/inet_ecn.h> 34e6445719SPravin B Shelar #include <net/ip_tunnels.h> 35e6445719SPravin B Shelar 36e6445719SPravin B Shelar #include "flow.h" 37e6445719SPravin B Shelar 38b637e498SPravin B Shelar struct table_instance { 39*ee9c5e67SKent Overstreet struct hlist_head *buckets; 40b637e498SPravin B Shelar unsigned int n_buckets; 41e6445719SPravin B Shelar struct rcu_head rcu; 42e6445719SPravin B Shelar int node_ver; 43e6445719SPravin B Shelar u32 hash_seed; 44e6445719SPravin B Shelar bool keep_flows; 45e6445719SPravin B Shelar }; 46e6445719SPravin B Shelar 47b637e498SPravin B Shelar struct flow_table { 48b637e498SPravin B Shelar struct table_instance __rcu *ti; 4974ed7ab9SJoe Stringer struct table_instance __rcu *ufid_ti; 50b637e498SPravin B Shelar struct list_head mask_list; 51b637e498SPravin B Shelar unsigned long last_rehash; 52b637e498SPravin B Shelar unsigned int count; 5374ed7ab9SJoe Stringer unsigned int ufid_count; 54b637e498SPravin B Shelar }; 55b637e498SPravin B Shelar 5663e7959cSJarno Rajahalme extern struct kmem_cache *flow_stats_cache; 5763e7959cSJarno Rajahalme 58e6445719SPravin B Shelar int ovs_flow_init(void); 59e6445719SPravin B Shelar void ovs_flow_exit(void); 60e6445719SPravin B Shelar 6123dabf88SJarno Rajahalme struct sw_flow *ovs_flow_alloc(void); 62e6445719SPravin B Shelar void ovs_flow_free(struct sw_flow *, bool deferred); 63e6445719SPravin B Shelar 64b637e498SPravin B Shelar int ovs_flow_tbl_init(struct flow_table *); 6512eb18f7SThomas Graf int ovs_flow_tbl_count(const struct flow_table *table); 669b996e54SPravin B Shelar void ovs_flow_tbl_destroy(struct flow_table *table); 67b637e498SPravin B Shelar int ovs_flow_tbl_flush(struct flow_table *flow_table); 68e6445719SPravin B Shelar 69618ed0c8SPravin B Shelar int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow, 7012eb18f7SThomas Graf const struct sw_flow_mask *mask); 71e6445719SPravin B Shelar void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow); 721bd7116fSAndy Zhou int ovs_flow_tbl_num_masks(const struct flow_table *table); 73b637e498SPravin B Shelar struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table, 74e6445719SPravin B Shelar u32 *bucket, u32 *idx); 755bb50632SAndy Zhou struct sw_flow *ovs_flow_tbl_lookup_stats(struct flow_table *, 761bd7116fSAndy Zhou const struct sw_flow_key *, 771bd7116fSAndy Zhou u32 *n_mask_hit); 785bb50632SAndy Zhou struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *, 795bb50632SAndy Zhou const struct sw_flow_key *); 804a46b24eSAlex Wang struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl, 8112eb18f7SThomas Graf const struct sw_flow_match *match); 8274ed7ab9SJoe Stringer struct sw_flow *ovs_flow_tbl_lookup_ufid(struct flow_table *, 8374ed7ab9SJoe Stringer const struct sw_flow_id *); 8474ed7ab9SJoe Stringer 8574ed7ab9SJoe Stringer bool ovs_flow_cmp(const struct sw_flow *, const struct sw_flow_match *); 86e6445719SPravin B Shelar 87e6445719SPravin B Shelar void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src, 88ae5f2fb1SJesse Gross bool full, const struct sw_flow_mask *mask); 89e6445719SPravin B Shelar #endif /* flow_table.h */ 90