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; 50b637e498SPravin B Shelar struct list_head mask_list; 51b637e498SPravin B Shelar unsigned long last_rehash; 52b637e498SPravin B Shelar unsigned int count; 53b637e498SPravin B Shelar }; 54b637e498SPravin B Shelar 55e6445719SPravin B Shelar int ovs_flow_init(void); 56e6445719SPravin B Shelar void ovs_flow_exit(void); 57e6445719SPravin B Shelar 58e6445719SPravin B Shelar struct sw_flow *ovs_flow_alloc(void); 59e6445719SPravin B Shelar void ovs_flow_free(struct sw_flow *, bool deferred); 60e6445719SPravin B Shelar 61b637e498SPravin B Shelar int ovs_flow_tbl_init(struct flow_table *); 62b637e498SPravin B Shelar int ovs_flow_tbl_count(struct flow_table *table); 63618ed0c8SPravin B Shelar void ovs_flow_tbl_destroy(struct flow_table *table); 64b637e498SPravin B Shelar int ovs_flow_tbl_flush(struct flow_table *flow_table); 65e6445719SPravin B Shelar 66618ed0c8SPravin B Shelar int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow, 67618ed0c8SPravin B Shelar struct sw_flow_mask *mask); 68e6445719SPravin B Shelar void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow); 691bd7116fSAndy Zhou int ovs_flow_tbl_num_masks(const struct flow_table *table); 70b637e498SPravin B Shelar struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table, 71e6445719SPravin B Shelar u32 *bucket, u32 *idx); 72*5bb50632SAndy Zhou struct sw_flow *ovs_flow_tbl_lookup_stats(struct flow_table *, 731bd7116fSAndy Zhou const struct sw_flow_key *, 741bd7116fSAndy Zhou u32 *n_mask_hit); 75*5bb50632SAndy Zhou struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *, 76*5bb50632SAndy Zhou const struct sw_flow_key *); 77e6445719SPravin B Shelar 78e6445719SPravin B Shelar bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow, 79e6445719SPravin B Shelar struct sw_flow_match *match); 80e6445719SPravin B Shelar 81e6445719SPravin B Shelar void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src, 82e6445719SPravin B Shelar const struct sw_flow_mask *mask); 83e6445719SPravin B Shelar #endif /* flow_table.h */ 84