at v5.2 2.2 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Copyright (c) 2007-2013 Nicira, Inc. 4 */ 5 6#ifndef FLOW_TABLE_H 7#define FLOW_TABLE_H 1 8 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> 19 20#include <net/inet_ecn.h> 21#include <net/ip_tunnels.h> 22 23#include "flow.h" 24 25struct table_instance { 26 struct hlist_head *buckets; 27 unsigned int n_buckets; 28 struct rcu_head rcu; 29 int node_ver; 30 u32 hash_seed; 31 bool keep_flows; 32}; 33 34struct flow_table { 35 struct table_instance __rcu *ti; 36 struct table_instance __rcu *ufid_ti; 37 struct list_head mask_list; 38 unsigned long last_rehash; 39 unsigned int count; 40 unsigned int ufid_count; 41}; 42 43extern struct kmem_cache *flow_stats_cache; 44 45int ovs_flow_init(void); 46void ovs_flow_exit(void); 47 48struct sw_flow *ovs_flow_alloc(void); 49void ovs_flow_free(struct sw_flow *, bool deferred); 50 51int ovs_flow_tbl_init(struct flow_table *); 52int ovs_flow_tbl_count(const struct flow_table *table); 53void ovs_flow_tbl_destroy(struct flow_table *table); 54int ovs_flow_tbl_flush(struct flow_table *flow_table); 55 56int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow, 57 const struct sw_flow_mask *mask); 58void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow); 59int ovs_flow_tbl_num_masks(const struct flow_table *table); 60struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table, 61 u32 *bucket, u32 *idx); 62struct sw_flow *ovs_flow_tbl_lookup_stats(struct flow_table *, 63 const struct sw_flow_key *, 64 u32 *n_mask_hit); 65struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *, 66 const struct sw_flow_key *); 67struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl, 68 const struct sw_flow_match *match); 69struct sw_flow *ovs_flow_tbl_lookup_ufid(struct flow_table *, 70 const struct sw_flow_id *); 71 72bool ovs_flow_cmp(const struct sw_flow *, const struct sw_flow_match *); 73 74void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src, 75 bool full, const struct sw_flow_mask *mask); 76#endif /* flow_table.h */