summaryrefslogtreecommitdiff
path: root/ofproto/ofproto-provider.h
diff options
context:
space:
mode:
authorJarno Rajahalme <jarno@ovn.org>2016-08-15 14:57:12 -0700
committerJarno Rajahalme <jarno@ovn.org>2016-08-15 14:57:12 -0700
commit5bacd5cdd6318306fb34dc42d1bd848eba19f551 (patch)
tree819c9782ead12e8c5282e0a9a24574dd4eee2465 /ofproto/ofproto-provider.h
parent70a3f6ce11a7e56cdcf621da576a1dfd98deabe4 (diff)
downloadopenvswitch-5bacd5cdd6318306fb34dc42d1bd848eba19f551.tar.gz
ofproto: Reduce bundle memory use.
Instead of storing the (big) struct ofputil_flow_mod, create the new rule and/or create the rule criteria for matching at bundle message insert time. This change reduces the size of a bundle flow mod from 3.5kb to 272 bytes, not counting the created rule, which was anyway created during bundle commit. In successful bundles this shifts work out of the ofproto_mutex critical section and should thus reduce the time the mutex is held during bundle commit. Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ofproto/ofproto-provider.h')
-rw-r--r--ofproto/ofproto-provider.h43
1 files changed, 41 insertions, 2 deletions
diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h
index 67a85e0a5..401d1b5e6 100644
--- a/ofproto/ofproto-provider.h
+++ b/ofproto/ofproto-provider.h
@@ -1838,25 +1838,64 @@ extern const struct ofproto_class ofproto_dpif_class;
int ofproto_class_register(const struct ofproto_class *);
int ofproto_class_unregister(const struct ofproto_class *);
+/* Criteria that flow_mod and other operations use for selecting rules on
+ * which to operate. */
+struct rule_criteria {
+ /* An OpenFlow table or 255 for all tables. */
+ uint8_t table_id;
+
+ /* OpenFlow matching criteria. Interpreted different in "loose" way by
+ * collect_rules_loose() and "strict" way by collect_rules_strict(), as
+ * defined in the OpenFlow spec. */
+ struct cls_rule cr;
+ ovs_version_t version;
+
+ /* Matching criteria for the OpenFlow cookie. Consider a bit B in a rule's
+ * cookie and the corresponding bits C in 'cookie' and M in 'cookie_mask'.
+ * The rule will not be selected if M is 1 and B != C. */
+ ovs_be64 cookie;
+ ovs_be64 cookie_mask;
+
+ /* Selection based on actions within a rule:
+ *
+ * If out_port != OFPP_ANY, selects only rules that output to out_port.
+ * If out_group != OFPG_ALL, select only rules that output to out_group. */
+ ofp_port_t out_port;
+ uint32_t out_group;
+
+ /* If true, collects only rules that are modifiable. */
+ bool include_hidden;
+ bool include_readonly;
+};
+
/* flow_mod with execution context. */
struct ofproto_flow_mod {
- struct ofputil_flow_mod fm;
+ /* Allocated by 'init' phase, may be freed after 'start' phase, as these
+ * are not needed for 'revert' nor 'finish'. */
+ struct rule *temp_rule;
+ struct rule_criteria criteria;
+ struct cls_conjunction *conjs;
+ size_t n_conjs;
/* Replicate needed fields from ofputil_flow_mod to not need it after the
* flow has been created. */
uint16_t command;
uint32_t buffer_id;
bool modify_cookie;
-
+ /* Fields derived from ofputil_flow_mod. */
bool modify_may_add_flow;
enum nx_flow_update_event event;
+ /* These are only used during commit execution.
+ * ofproto_flow_mod_uninit() does NOT clean these up. */
ovs_version_t version; /* Version in which changes take
* effect. */
struct rule_collection old_rules; /* Affected rules. */
struct rule_collection new_rules; /* Replacement rules. */
};
+void ofproto_flow_mod_uninit(struct ofproto_flow_mod *);
+
/* port_mod with execution context. */
struct ofproto_port_mod {
struct ofputil_port_mod pm;