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 #include <linux/flex_array.h> 33e6445719SPravin B Shelar 34e6445719SPravin B Shelar #include <net/inet_ecn.h> 35e6445719SPravin B Shelar #include <net/ip_tunnels.h> 36e6445719SPravin B Shelar 37e6445719SPravin B Shelar #include "flow.h" 38e6445719SPravin B Shelar 39b637e498SPravin B Shelar struct table_instance { 40e6445719SPravin B Shelar struct flex_array *buckets; 41b637e498SPravin B Shelar unsigned int n_buckets; 42e6445719SPravin B Shelar struct rcu_head rcu; 43e6445719SPravin B Shelar int node_ver; 44e6445719SPravin B Shelar u32 hash_seed; 45e6445719SPravin B Shelar bool keep_flows; 46e6445719SPravin B Shelar }; 47e6445719SPravin B Shelar 48b637e498SPravin B Shelar struct flow_table { 49b637e498SPravin B Shelar struct table_instance __rcu *ti; 5074ed7ab9SJoe Stringer struct table_instance __rcu *ufid_ti; 51b637e498SPravin B Shelar struct list_head mask_list; 52b637e498SPravin B Shelar unsigned long last_rehash; 53b637e498SPravin B Shelar unsigned int count; 5474ed7ab9SJoe Stringer unsigned int ufid_count; 55b637e498SPravin B Shelar }; 56b637e498SPravin B Shelar 5763e7959cSJarno Rajahalme extern struct kmem_cache *flow_stats_cache; 5863e7959cSJarno Rajahalme 59e6445719SPravin B Shelar int ovs_flow_init(void); 60e6445719SPravin B Shelar void ovs_flow_exit(void); 61e6445719SPravin B Shelar 6223dabf88SJarno Rajahalme struct sw_flow *ovs_flow_alloc(void); 63e6445719SPravin B Shelar void ovs_flow_free(struct sw_flow *, bool deferred); 64e6445719SPravin B Shelar 65b637e498SPravin B Shelar int ovs_flow_tbl_init(struct flow_table *); 6612eb18f7SThomas Graf int ovs_flow_tbl_count(const struct flow_table *table); 679b996e54SPravin B Shelar void ovs_flow_tbl_destroy(struct flow_table *table); 68b637e498SPravin B Shelar int ovs_flow_tbl_flush(struct flow_table *flow_table); 69e6445719SPravin B Shelar 70618ed0c8SPravin B Shelar int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow, 7112eb18f7SThomas Graf const struct sw_flow_mask *mask); 72e6445719SPravin B Shelar void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow); 731bd7116fSAndy Zhou int ovs_flow_tbl_num_masks(const struct flow_table *table); 74b637e498SPravin B Shelar struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table, 75e6445719SPravin B Shelar u32 *bucket, u32 *idx); 765bb50632SAndy Zhou struct sw_flow *ovs_flow_tbl_lookup_stats(struct flow_table *, 771bd7116fSAndy Zhou const struct sw_flow_key *, 781bd7116fSAndy Zhou u32 *n_mask_hit); 795bb50632SAndy Zhou struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *, 805bb50632SAndy Zhou const struct sw_flow_key *); 814a46b24eSAlex Wang struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl, 8212eb18f7SThomas Graf const struct sw_flow_match *match); 8374ed7ab9SJoe Stringer struct sw_flow *ovs_flow_tbl_lookup_ufid(struct flow_table *, 8474ed7ab9SJoe Stringer const struct sw_flow_id *); 8574ed7ab9SJoe Stringer 8674ed7ab9SJoe Stringer bool ovs_flow_cmp(const struct sw_flow *, const struct sw_flow_match *); 87e6445719SPravin B Shelar 88e6445719SPravin B Shelar void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src, 89*ae5f2fb1SJesse Gross bool full, const struct sw_flow_mask *mask); 90e6445719SPravin B Shelar #endif /* flow_table.h */ 91