mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 08:44:21 +08:00
ee9c5e6755
Patch series "generic radix trees; drop flex arrays". This patch (of 7): There was no real need for this code to be using flexarrays, it's just implementing a hash table - ideally it would be using rhashtables, but that conversion would be significantly more complicated. Link: http://lkml.kernel.org/r/20181217131929.11727-2-kent.overstreet@gmail.com Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Reviewed-by: Matthew Wilcox <willy@infradead.org> Cc: Pravin B Shelar <pshelar@ovn.org> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Eric Paris <eparis@parisplace.org> Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Cc: Neil Horman <nhorman@tuxdriver.com> Cc: Paul Moore <paul@paul-moore.com> Cc: Shaohua Li <shli@kernel.org> Cc: Stephen Smalley <sds@tycho.nsa.gov> Cc: Vlad Yasevich <vyasevich@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
90 lines
2.8 KiB
C
90 lines
2.8 KiB
C
/*
|
|
* Copyright (c) 2007-2013 Nicira, Inc.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of version 2 of the GNU General Public
|
|
* License as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
* 02110-1301, USA
|
|
*/
|
|
|
|
#ifndef FLOW_TABLE_H
|
|
#define FLOW_TABLE_H 1
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/netlink.h>
|
|
#include <linux/openvswitch.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/types.h>
|
|
#include <linux/rcupdate.h>
|
|
#include <linux/if_ether.h>
|
|
#include <linux/in6.h>
|
|
#include <linux/jiffies.h>
|
|
#include <linux/time.h>
|
|
|
|
#include <net/inet_ecn.h>
|
|
#include <net/ip_tunnels.h>
|
|
|
|
#include "flow.h"
|
|
|
|
struct table_instance {
|
|
struct hlist_head *buckets;
|
|
unsigned int n_buckets;
|
|
struct rcu_head rcu;
|
|
int node_ver;
|
|
u32 hash_seed;
|
|
bool keep_flows;
|
|
};
|
|
|
|
struct flow_table {
|
|
struct table_instance __rcu *ti;
|
|
struct table_instance __rcu *ufid_ti;
|
|
struct list_head mask_list;
|
|
unsigned long last_rehash;
|
|
unsigned int count;
|
|
unsigned int ufid_count;
|
|
};
|
|
|
|
extern struct kmem_cache *flow_stats_cache;
|
|
|
|
int ovs_flow_init(void);
|
|
void ovs_flow_exit(void);
|
|
|
|
struct sw_flow *ovs_flow_alloc(void);
|
|
void ovs_flow_free(struct sw_flow *, bool deferred);
|
|
|
|
int ovs_flow_tbl_init(struct flow_table *);
|
|
int ovs_flow_tbl_count(const struct flow_table *table);
|
|
void ovs_flow_tbl_destroy(struct flow_table *table);
|
|
int ovs_flow_tbl_flush(struct flow_table *flow_table);
|
|
|
|
int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow,
|
|
const struct sw_flow_mask *mask);
|
|
void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow);
|
|
int ovs_flow_tbl_num_masks(const struct flow_table *table);
|
|
struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table,
|
|
u32 *bucket, u32 *idx);
|
|
struct sw_flow *ovs_flow_tbl_lookup_stats(struct flow_table *,
|
|
const struct sw_flow_key *,
|
|
u32 *n_mask_hit);
|
|
struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *,
|
|
const struct sw_flow_key *);
|
|
struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl,
|
|
const struct sw_flow_match *match);
|
|
struct sw_flow *ovs_flow_tbl_lookup_ufid(struct flow_table *,
|
|
const struct sw_flow_id *);
|
|
|
|
bool ovs_flow_cmp(const struct sw_flow *, const struct sw_flow_match *);
|
|
|
|
void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src,
|
|
bool full, const struct sw_flow_mask *mask);
|
|
#endif /* flow_table.h */
|