hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/net/openvswitch/flow_table.h
....@@ -1,19 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * 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
174 */
185
196 #ifndef FLOW_TABLE_H
....@@ -29,26 +16,54 @@
2916 #include <linux/in6.h>
3017 #include <linux/jiffies.h>
3118 #include <linux/time.h>
32
-#include <linux/flex_array.h>
3319
3420 #include <net/inet_ecn.h>
3521 #include <net/ip_tunnels.h>
3622
3723 #include "flow.h"
3824
25
+struct mask_cache_entry {
26
+ u32 skb_hash;
27
+ u32 mask_index;
28
+};
29
+
30
+struct mask_cache {
31
+ struct rcu_head rcu;
32
+ u32 cache_size; /* Must be ^2 value. */
33
+ struct mask_cache_entry __percpu *mask_cache;
34
+};
35
+
36
+struct mask_count {
37
+ int index;
38
+ u64 counter;
39
+};
40
+
41
+struct mask_array_stats {
42
+ struct u64_stats_sync syncp;
43
+ u64 usage_cntrs[];
44
+};
45
+
46
+struct mask_array {
47
+ struct rcu_head rcu;
48
+ int count, max;
49
+ struct mask_array_stats __percpu *masks_usage_stats;
50
+ u64 *masks_usage_zero_cntr;
51
+ struct sw_flow_mask __rcu *masks[];
52
+};
53
+
3954 struct table_instance {
40
- struct flex_array *buckets;
55
+ struct hlist_head *buckets;
4156 unsigned int n_buckets;
4257 struct rcu_head rcu;
4358 int node_ver;
4459 u32 hash_seed;
45
- bool keep_flows;
4660 };
4761
4862 struct flow_table {
4963 struct table_instance __rcu *ti;
5064 struct table_instance __rcu *ufid_ti;
51
- struct list_head mask_list;
65
+ struct mask_cache __rcu *mask_cache;
66
+ struct mask_array __rcu *mask_array;
5267 unsigned long last_rehash;
5368 unsigned int count;
5469 unsigned int ufid_count;
....@@ -71,11 +86,15 @@
7186 const struct sw_flow_mask *mask);
7287 void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow);
7388 int ovs_flow_tbl_num_masks(const struct flow_table *table);
89
+u32 ovs_flow_tbl_masks_cache_size(const struct flow_table *table);
90
+int ovs_flow_tbl_masks_cache_resize(struct flow_table *table, u32 size);
7491 struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table,
7592 u32 *bucket, u32 *idx);
7693 struct sw_flow *ovs_flow_tbl_lookup_stats(struct flow_table *,
77
- const struct sw_flow_key *,
78
- u32 *n_mask_hit);
94
+ const struct sw_flow_key *,
95
+ u32 skb_hash,
96
+ u32 *n_mask_hit,
97
+ u32 *n_cache_hit);
7998 struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *,
8099 const struct sw_flow_key *);
81100 struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl,
....@@ -87,4 +106,10 @@
87106
88107 void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src,
89108 bool full, const struct sw_flow_mask *mask);
109
+
110
+void ovs_flow_masks_rebalance(struct flow_table *table);
111
+void table_instance_flow_flush(struct flow_table *table,
112
+ struct table_instance *ti,
113
+ struct table_instance *ufid_ti);
114
+
90115 #endif /* flow_table.h */