]> git.proxmox.com Git - mirror_ovs.git/blame - datapath/flow_table.h
datapath: Fix exposing OVS_TUNNEL_KEY_ATTR_GTPU_OPTS to kernel module.
[mirror_ovs.git] / datapath / flow_table.h
CommitLineData
a097c0b2
PS
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>
a097c0b2
PS
32
33#include <net/inet_ecn.h>
34#include <net/ip_tunnels.h>
35
36#include "flow.h"
37
5604935e
PS
38struct mask_cache_entry {
39 u32 skb_hash;
40 u32 mask_index;
41};
42
d49fc3ff
PS
43struct mask_array {
44 struct rcu_head rcu;
45 int count, max;
46 struct sw_flow_mask __rcu *masks[];
47};
48
994dc286 49struct table_instance {
4383e54b 50 struct hlist_head *buckets;
994dc286 51 unsigned int n_buckets;
a097c0b2 52 struct rcu_head rcu;
a097c0b2
PS
53 int node_ver;
54 u32 hash_seed;
55 bool keep_flows;
56};
57
994dc286
PS
58struct flow_table {
59 struct table_instance __rcu *ti;
bc619e29 60 struct table_instance __rcu *ufid_ti;
5604935e 61 struct mask_cache_entry __percpu *mask_cache;
d49fc3ff 62 struct mask_array __rcu *mask_array;
994dc286
PS
63 unsigned long last_rehash;
64 unsigned int count;
bc619e29 65 unsigned int ufid_count;
994dc286
PS
66};
67
9ac56358
JR
68extern struct kmem_cache *flow_stats_cache;
69
a097c0b2
PS
70int ovs_flow_init(void);
71void ovs_flow_exit(void);
72
df65fec1 73struct sw_flow *ovs_flow_alloc(void);
a097c0b2
PS
74void ovs_flow_free(struct sw_flow *, bool deferred);
75
994dc286 76int ovs_flow_tbl_init(struct flow_table *);
f1f60b85 77int ovs_flow_tbl_count(const struct flow_table *table);
e379e4d1 78void ovs_flow_tbl_destroy(struct flow_table *table);
994dc286 79int ovs_flow_tbl_flush(struct flow_table *flow_table);
a097c0b2 80
0585f7a8 81int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow,
f1f60b85 82 const struct sw_flow_mask *mask);
a097c0b2 83void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow);
4fa72a95 84int ovs_flow_tbl_num_masks(const struct flow_table *table);
994dc286 85struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table,
a097c0b2 86 u32 *bucket, u32 *idx);
4f88b5e5 87struct sw_flow *ovs_flow_tbl_lookup_stats(struct flow_table *,
5604935e
PS
88 const struct sw_flow_key *,
89 u32 skb_hash,
90 u32 *n_mask_hit);
4f88b5e5
AZ
91struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *,
92 const struct sw_flow_key *);
7d16c847 93struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl,
f1f60b85 94 const struct sw_flow_match *match);
bc619e29
JS
95struct sw_flow *ovs_flow_tbl_lookup_ufid(struct flow_table *,
96 const struct sw_flow_id *);
97
98bool ovs_flow_cmp(const struct sw_flow *, const struct sw_flow_match *);
a097c0b2 99
a097c0b2 100void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src,
ad4adec2 101 bool full, const struct sw_flow_mask *mask);
a097c0b2 102#endif /* flow_table.h */