| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * 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 | 4 | */ |
|---|
| 18 | 5 | |
|---|
| 19 | 6 | #ifndef FLOW_TABLE_H |
|---|
| .. | .. |
|---|
| 29 | 16 | #include <linux/in6.h> |
|---|
| 30 | 17 | #include <linux/jiffies.h> |
|---|
| 31 | 18 | #include <linux/time.h> |
|---|
| 32 | | -#include <linux/flex_array.h> |
|---|
| 33 | 19 | |
|---|
| 34 | 20 | #include <net/inet_ecn.h> |
|---|
| 35 | 21 | #include <net/ip_tunnels.h> |
|---|
| 36 | 22 | |
|---|
| 37 | 23 | #include "flow.h" |
|---|
| 38 | 24 | |
|---|
| 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 | + |
|---|
| 39 | 54 | struct table_instance { |
|---|
| 40 | | - struct flex_array *buckets; |
|---|
| 55 | + struct hlist_head *buckets; |
|---|
| 41 | 56 | unsigned int n_buckets; |
|---|
| 42 | 57 | struct rcu_head rcu; |
|---|
| 43 | 58 | int node_ver; |
|---|
| 44 | 59 | u32 hash_seed; |
|---|
| 45 | | - bool keep_flows; |
|---|
| 46 | 60 | }; |
|---|
| 47 | 61 | |
|---|
| 48 | 62 | struct flow_table { |
|---|
| 49 | 63 | struct table_instance __rcu *ti; |
|---|
| 50 | 64 | 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; |
|---|
| 52 | 67 | unsigned long last_rehash; |
|---|
| 53 | 68 | unsigned int count; |
|---|
| 54 | 69 | unsigned int ufid_count; |
|---|
| .. | .. |
|---|
| 71 | 86 | const struct sw_flow_mask *mask); |
|---|
| 72 | 87 | void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow); |
|---|
| 73 | 88 | 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); |
|---|
| 74 | 91 | struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table, |
|---|
| 75 | 92 | u32 *bucket, u32 *idx); |
|---|
| 76 | 93 | 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); |
|---|
| 79 | 98 | struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *, |
|---|
| 80 | 99 | const struct sw_flow_key *); |
|---|
| 81 | 100 | struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl, |
|---|
| .. | .. |
|---|
| 87 | 106 | |
|---|
| 88 | 107 | void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src, |
|---|
| 89 | 108 | 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 | + |
|---|
| 90 | 115 | #endif /* flow_table.h */ |
|---|