blob: 2dd9900f533df364fb5fb7b1772b9805b28092cc [file] [log] [blame]
Pravin B Shelare6445712013-10-03 18:16:47 -07001/*
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
Pravin B Shelarb637e492013-10-04 00:14:23 -070039struct table_instance {
Pravin B Shelare6445712013-10-03 18:16:47 -070040 struct flex_array *buckets;
Pravin B Shelarb637e492013-10-04 00:14:23 -070041 unsigned int n_buckets;
Pravin B Shelare6445712013-10-03 18:16:47 -070042 struct rcu_head rcu;
Pravin B Shelare6445712013-10-03 18:16:47 -070043 int node_ver;
44 u32 hash_seed;
45 bool keep_flows;
46};
47
Pravin B Shelarb637e492013-10-04 00:14:23 -070048struct flow_table {
49 struct table_instance __rcu *ti;
Joe Stringer74ed7ab2015-01-21 16:42:52 -080050 struct table_instance __rcu *ufid_ti;
Pravin B Shelarb637e492013-10-04 00:14:23 -070051 struct list_head mask_list;
52 unsigned long last_rehash;
53 unsigned int count;
Joe Stringer74ed7ab2015-01-21 16:42:52 -080054 unsigned int ufid_count;
Pravin B Shelarb637e492013-10-04 00:14:23 -070055};
56
Jarno Rajahalme63e79592014-03-27 12:42:54 -070057extern struct kmem_cache *flow_stats_cache;
58
Pravin B Shelare6445712013-10-03 18:16:47 -070059int ovs_flow_init(void);
60void ovs_flow_exit(void);
61
Jarno Rajahalme23dabf82014-03-27 12:35:23 -070062struct sw_flow *ovs_flow_alloc(void);
Pravin B Shelare6445712013-10-03 18:16:47 -070063void ovs_flow_free(struct sw_flow *, bool deferred);
64
Pravin B Shelarb637e492013-10-04 00:14:23 -070065int ovs_flow_tbl_init(struct flow_table *);
Thomas Graf12eb18f2014-11-06 06:58:52 -080066int ovs_flow_tbl_count(const struct flow_table *table);
Pravin B Shelar9b996e52014-05-06 18:41:20 -070067void ovs_flow_tbl_destroy(struct flow_table *table);
Pravin B Shelarb637e492013-10-04 00:14:23 -070068int ovs_flow_tbl_flush(struct flow_table *flow_table);
Pravin B Shelare6445712013-10-03 18:16:47 -070069
Pravin B Shelar618ed0c2013-10-04 00:17:42 -070070int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow,
Thomas Graf12eb18f2014-11-06 06:58:52 -080071 const struct sw_flow_mask *mask);
Pravin B Shelare6445712013-10-03 18:16:47 -070072void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow);
Andy Zhou1bd71162013-10-22 10:42:46 -070073int ovs_flow_tbl_num_masks(const struct flow_table *table);
Pravin B Shelarb637e492013-10-04 00:14:23 -070074struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table,
Pravin B Shelare6445712013-10-03 18:16:47 -070075 u32 *bucket, u32 *idx);
Andy Zhou5bb50632013-11-25 10:42:46 -080076struct sw_flow *ovs_flow_tbl_lookup_stats(struct flow_table *,
Andy Zhou1bd71162013-10-22 10:42:46 -070077 const struct sw_flow_key *,
78 u32 *n_mask_hit);
Andy Zhou5bb50632013-11-25 10:42:46 -080079struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *,
80 const struct sw_flow_key *);
Alex Wang4a46b242014-06-30 20:30:29 -070081struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl,
Thomas Graf12eb18f2014-11-06 06:58:52 -080082 const struct sw_flow_match *match);
Joe Stringer74ed7ab2015-01-21 16:42:52 -080083struct sw_flow *ovs_flow_tbl_lookup_ufid(struct flow_table *,
84 const struct sw_flow_id *);
85
86bool ovs_flow_cmp(const struct sw_flow *, const struct sw_flow_match *);
Pravin B Shelare6445712013-10-03 18:16:47 -070087
Pravin B Shelare6445712013-10-03 18:16:47 -070088void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src,
Jesse Grossae5f2fb2015-09-21 20:21:20 -070089 bool full, const struct sw_flow_mask *mask);
Pravin B Shelare6445712013-10-03 18:16:47 -070090#endif /* flow_table.h */