Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2007-2013 Nicira, Inc.
0004  */
0005 
0006 #ifndef FLOW_TABLE_H
0007 #define FLOW_TABLE_H 1
0008 
0009 #include <linux/kernel.h>
0010 #include <linux/netlink.h>
0011 #include <linux/openvswitch.h>
0012 #include <linux/spinlock.h>
0013 #include <linux/types.h>
0014 #include <linux/rcupdate.h>
0015 #include <linux/if_ether.h>
0016 #include <linux/in6.h>
0017 #include <linux/jiffies.h>
0018 #include <linux/time.h>
0019 
0020 #include <net/inet_ecn.h>
0021 #include <net/ip_tunnels.h>
0022 
0023 #include "flow.h"
0024 
0025 struct mask_cache_entry {
0026     u32 skb_hash;
0027     u32 mask_index;
0028 };
0029 
0030 struct mask_cache {
0031     struct rcu_head rcu;
0032     u32 cache_size;  /* Must be ^2 value. */
0033     struct mask_cache_entry __percpu *mask_cache;
0034 };
0035 
0036 struct mask_count {
0037     int index;
0038     u64 counter;
0039 };
0040 
0041 struct mask_array_stats {
0042     struct u64_stats_sync syncp;
0043     u64 usage_cntrs[];
0044 };
0045 
0046 struct mask_array {
0047     struct rcu_head rcu;
0048     int count, max;
0049     struct mask_array_stats __percpu *masks_usage_stats;
0050     u64 *masks_usage_zero_cntr;
0051     struct sw_flow_mask __rcu *masks[];
0052 };
0053 
0054 struct table_instance {
0055     struct hlist_head *buckets;
0056     unsigned int n_buckets;
0057     struct rcu_head rcu;
0058     int node_ver;
0059     u32 hash_seed;
0060 };
0061 
0062 struct flow_table {
0063     struct table_instance __rcu *ti;
0064     struct table_instance __rcu *ufid_ti;
0065     struct mask_cache __rcu *mask_cache;
0066     struct mask_array __rcu *mask_array;
0067     unsigned long last_rehash;
0068     unsigned int count;
0069     unsigned int ufid_count;
0070 };
0071 
0072 extern struct kmem_cache *flow_stats_cache;
0073 
0074 int ovs_flow_init(void);
0075 void ovs_flow_exit(void);
0076 
0077 struct sw_flow *ovs_flow_alloc(void);
0078 void ovs_flow_free(struct sw_flow *, bool deferred);
0079 
0080 int ovs_flow_tbl_init(struct flow_table *);
0081 int ovs_flow_tbl_count(const struct flow_table *table);
0082 void ovs_flow_tbl_destroy(struct flow_table *table);
0083 int ovs_flow_tbl_flush(struct flow_table *flow_table);
0084 
0085 int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow,
0086             const struct sw_flow_mask *mask);
0087 void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow);
0088 int  ovs_flow_tbl_num_masks(const struct flow_table *table);
0089 u32  ovs_flow_tbl_masks_cache_size(const struct flow_table *table);
0090 int  ovs_flow_tbl_masks_cache_resize(struct flow_table *table, u32 size);
0091 struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table,
0092                        u32 *bucket, u32 *idx);
0093 struct sw_flow *ovs_flow_tbl_lookup_stats(struct flow_table *,
0094                       const struct sw_flow_key *,
0095                       u32 skb_hash,
0096                       u32 *n_mask_hit,
0097                       u32 *n_cache_hit);
0098 struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *,
0099                     const struct sw_flow_key *);
0100 struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl,
0101                       const struct sw_flow_match *match);
0102 struct sw_flow *ovs_flow_tbl_lookup_ufid(struct flow_table *,
0103                      const struct sw_flow_id *);
0104 
0105 bool ovs_flow_cmp(const struct sw_flow *, const struct sw_flow_match *);
0106 
0107 void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src,
0108                bool full, const struct sw_flow_mask *mask);
0109 
0110 void ovs_flow_masks_rebalance(struct flow_table *table);
0111 void table_instance_flow_flush(struct flow_table *table,
0112                    struct table_instance *ti,
0113                    struct table_instance *ufid_ti);
0114 
0115 #endif /* flow_table.h */