Add support for OFPFC_MODIFY Flow Mod command.
[openvswitch] / datapath / table.h
index b0681b6a5ded24ed81df002e77d7c8d2ed62b1e3..8cbcfb7a6d0880d7d4013748923e88b47e04cd20 100644 (file)
@@ -8,13 +8,17 @@
 
 struct sw_flow;
 struct sw_flow_key;
+struct ofp_action;
 struct datapath;
 
 /* Table statistics. */
 struct sw_table_stats {
-       const char *name;       /* Human-readable name. */
-       unsigned long int n_flows; /* Number of active flows. */
-       unsigned long int max_flows; /* Flow capacity. */
+       const char *name;            /* Human-readable name. */
+       uint32_t wildcards;          /* Bitmap of OFPFW_* wildcards that are
+                                       supported by the table. */
+       unsigned int n_flows;        /* Number of active flows. */
+       unsigned int max_flows;      /* Flow capacity. */
+       unsigned long int n_matched; /* Number of packets that have hit. */
 };
 
 /* Position within an iteration of a sw_table.
@@ -31,6 +35,11 @@ struct sw_table_position {
  * rcu_read_lock.  destroy must be fully serialized.
  */
 struct sw_table {
+       /* Keep track of the number of packets that matched this table.  To
+        * make this 100% accurate, it should be atomic.  However, we're
+        * primarily concerned about speed. */
+       unsigned long int n_matched;
+
        /* Searches 'table' for a flow matching 'key', which must not have any
         * wildcard fields.  Returns the flow if successful, a null pointer
         * otherwise. */
@@ -46,6 +55,11 @@ struct sw_table {
         * retained by the caller. */
        int (*insert)(struct sw_table *table, struct sw_flow *flow);
 
+       /* Modifies the actions in 'table' that match 'key'.  Returns the
+        * number of flows that were modified. */
+       int (*modify)(struct sw_table *table, const struct sw_flow_key *key,
+                       const struct ofp_action *actions, int n_actions);
+
        /* Deletes from 'table' any and all flows that match 'key' from
         * 'table'.  If 'strict' set, wildcards and priority must match.  
         * Returns the number of flows that were deleted. */
@@ -69,8 +83,9 @@ struct sw_table {
         * all-zero-bits to iterate from the beginning of the table.  If the
         * iteration terminates due to an error from the callback function,
         * 'position' is updated to a value that can be passed back to the
-        * iterator function to resume iteration later with the following
-        * flow. */
+        * iterator function to continue iteration later from the same position
+        * that caused the error (assuming that that flow entry has not been
+        * deleted in the meantime). */
        int (*iterate)(struct sw_table *table,
                       const struct sw_flow_key *key,
                       struct sw_table_position *position,