1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2007-2013 Nicira, Inc.
9 #include <linux/kernel.h>
10 #include <linux/netlink.h>
11 #include <linux/openvswitch.h>
12 #include <linux/spinlock.h>
13 #include <linux/types.h>
14 #include <linux/rcupdate.h>
15 #include <linux/if_ether.h>
16 #include <linux/in6.h>
17 #include <linux/jiffies.h>
18 #include <linux/time.h>
20 #include <net/inet_ecn.h>
21 #include <net/ip_tunnels.h>
25 struct mask_cache_entry
{
32 u32 cache_size
; /* Must be ^2 value. */
33 struct mask_cache_entry __percpu
*mask_cache
;
44 u64 __percpu
*masks_usage_cntr
;
45 u64
*masks_usage_zero_cntr
;
46 struct u64_stats_sync syncp
;
47 struct sw_flow_mask __rcu
*masks
[];
50 struct table_instance
{
51 struct hlist_head
*buckets
;
52 unsigned int n_buckets
;
59 struct table_instance __rcu
*ti
;
60 struct table_instance __rcu
*ufid_ti
;
61 struct mask_cache __rcu
*mask_cache
;
62 struct mask_array __rcu
*mask_array
;
63 unsigned long last_rehash
;
65 unsigned int ufid_count
;
68 extern struct kmem_cache
*flow_stats_cache
;
70 int ovs_flow_init(void);
71 void ovs_flow_exit(void);
73 struct sw_flow
*ovs_flow_alloc(void);
74 void ovs_flow_free(struct sw_flow
*, bool deferred
);
76 int ovs_flow_tbl_init(struct flow_table
*);
77 int ovs_flow_tbl_count(const struct flow_table
*table
);
78 void ovs_flow_tbl_destroy(struct flow_table
*table
);
79 int ovs_flow_tbl_flush(struct flow_table
*flow_table
);
81 int ovs_flow_tbl_insert(struct flow_table
*table
, struct sw_flow
*flow
,
82 const struct sw_flow_mask
*mask
);
83 void ovs_flow_tbl_remove(struct flow_table
*table
, struct sw_flow
*flow
);
84 int ovs_flow_tbl_num_masks(const struct flow_table
*table
);
85 u32
ovs_flow_tbl_masks_cache_size(const struct flow_table
*table
);
86 int ovs_flow_tbl_masks_cache_resize(struct flow_table
*table
, u32 size
);
87 struct sw_flow
*ovs_flow_tbl_dump_next(struct table_instance
*table
,
88 u32
*bucket
, u32
*idx
);
89 struct sw_flow
*ovs_flow_tbl_lookup_stats(struct flow_table
*,
90 const struct sw_flow_key
*,
94 struct sw_flow
*ovs_flow_tbl_lookup(struct flow_table
*,
95 const struct sw_flow_key
*);
96 struct sw_flow
*ovs_flow_tbl_lookup_exact(struct flow_table
*tbl
,
97 const struct sw_flow_match
*match
);
98 struct sw_flow
*ovs_flow_tbl_lookup_ufid(struct flow_table
*,
99 const struct sw_flow_id
*);
101 bool ovs_flow_cmp(const struct sw_flow
*, const struct sw_flow_match
*);
103 void ovs_flow_mask_key(struct sw_flow_key
*dst
, const struct sw_flow_key
*src
,
104 bool full
, const struct sw_flow_mask
*mask
);
106 void ovs_flow_masks_rebalance(struct flow_table
*table
);
107 void table_instance_flow_flush(struct flow_table
*table
,
108 struct table_instance
*ti
,
109 struct table_instance
*ufid_ti
);
111 #endif /* flow_table.h */