Remove MAC table support.
[sliver-openvswitch.git] / datapath / table.h
1 /* Individual switching tables.  Generally grouped together in a chain (see
2  * chain.h). */
3
4 #ifndef TABLE_H
5 #define TABLE_H 1
6
7 struct sw_flow;
8 struct sw_flow_key;
9 struct datapath;
10
11 /* Iterator through the flows stored in a table. */
12 struct swt_iterator {
13         struct sw_flow *flow;   /* Current flow, for use by client. */
14         void *private;
15 };
16
17 /* Table statistics. */
18 struct sw_table_stats {
19         const char *name;       /* Human-readable name. */
20         unsigned long int n_flows; /* Number of active flows. */
21         unsigned long int max_flows; /* Flow capacity. */
22 };
23
24 /* A single table of flows.
25  *
26  * All functions, except destroy, must be called holding the
27  * rcu_read_lock.  destroy must be fully serialized.
28  */
29 struct sw_table {
30         /* Searches 'table' for a flow matching 'key', which must not have any
31          * wildcard fields.  Returns the flow if successful, a null pointer
32          * otherwise. */
33         struct sw_flow *(*lookup)(struct sw_table *table,
34                         const struct sw_flow_key *key);
35
36         /* Inserts 'flow' into 'table', replacing any duplicate flow.  Returns
37          * 0 if successful or a negative error.  Error can be due to an
38          * over-capacity table or because the flow is not one of the kind that
39          * the table accepts.
40          *
41          * If successful, 'flow' becomes owned by 'table', otherwise it is
42          * retained by the caller. */
43         int (*insert)(struct sw_table *table, struct sw_flow *flow);
44
45         /* Deletes from 'table' any and all flows that match 'key' from
46          * 'table'.  If 'strict' set, wildcards must match.  Returns the 
47          * number of flows that were deleted. */
48         int (*delete)(struct sw_table *table, const struct sw_flow_key *key, 
49                         int strict);
50
51         /* Performs timeout processing on all the flow entries in 'table'.
52          * Returns the number of flow entries deleted through expiration. */
53         int (*timeout)(struct datapath *dp, struct sw_table *table);
54
55         /* Destroys 'table', which must not have any users. */
56         void (*destroy)(struct sw_table *table);
57
58         int (*iterator)(struct sw_table *, struct swt_iterator *);
59         void (*iterator_next)(struct swt_iterator *);
60         void (*iterator_destroy)(struct swt_iterator *);
61
62         /* Dumps statistics for 'table' into 'stats'. */
63         void (*stats)(struct sw_table *table, struct sw_table_stats *stats);
64 };
65
66 struct sw_table *table_hash_create(unsigned int polynomial,
67                 unsigned int n_buckets);
68 struct sw_table *table_hash2_create(unsigned int poly0, unsigned int buckets0,
69                 unsigned int poly1, unsigned int buckets1);
70 struct sw_table *table_linear_create(unsigned int max_flows);
71
72 #endif /* table.h */