1 /* Individual switching tables. Generally grouped together in a chain (see
11 /* Iterator through the flows stored in a table. */
13 struct sw_flow *flow; /* Current flow, for use by client. */
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. */
24 /* A single table of flows.
26 * All functions, except destroy, must be called holding the
27 * rcu_read_lock. destroy must be fully serialized.
30 /* Searches 'table' for a flow matching 'key', which must not have any
31 * wildcard fields. Returns the flow if successful, a null pointer
33 struct sw_flow *(*lookup)(struct sw_table *table,
34 const struct sw_flow_key *key);
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
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);
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,
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);
55 /* Destroys 'table', which must not have any users. */
56 void (*destroy)(struct sw_table *table);
58 int (*iterator)(struct sw_table *, struct swt_iterator *);
59 void (*iterator_next)(struct swt_iterator *);
60 void (*iterator_destroy)(struct swt_iterator *);
62 /* Dumps statistics for 'table' into 'stats'. */
63 void (*stats)(struct sw_table *table, struct sw_table_stats *stats);
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);