[ovs-dev] [threaded-put 14/21] ofproto-dpif-xlate: Add a mechanism to skip wildcard calculation.

Ethan Jackson ethan at nicira.com
Mon Dec 9 02:45:20 UTC 2013


As time goes on and the classifier becomes more complicated, calculate
the wildcard mask will get more and more expensive.  This patch adds a
mechanism to xlate_actions() allowing callers to disable wildcard
calculation when it isn't really necessary.  Used in future patches.

Signed-off-by: Ethan Jackson <ethan at nicira.com>
---
 ofproto/ofproto-dpif-xlate.c | 10 ++++++----
 ofproto/ofproto-dpif-xlate.h |  6 ++++++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index da03f06..58ec484 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -1870,9 +1870,10 @@ xlate_table_action(struct xlate_ctx *ctx,
                    ofp_port_t in_port, uint8_t table_id, bool may_packet_in)
 {
     if (xlate_resubmit_resource_check(ctx)) {
-        struct rule_dpif *rule;
         ofp_port_t old_in_port = ctx->xin->flow.in_port.ofp_port;
+        bool skip_wildcards = ctx->xin->skip_wildcards;
         uint8_t old_table_id = ctx->table_id;
+        struct rule_dpif *rule;
 
         ctx->table_id = table_id;
 
@@ -1880,8 +1881,8 @@ xlate_table_action(struct xlate_ctx *ctx,
          * original input port (otherwise OFPP_NORMAL and OFPP_IN_PORT will
          * have surprising behavior). */
         ctx->xin->flow.in_port.ofp_port = in_port;
-        rule_dpif_lookup_in_table(ctx->xbridge->ofproto,
-                                  &ctx->xin->flow, &ctx->xout->wc,
+        rule_dpif_lookup_in_table(ctx->xbridge->ofproto, &ctx->xin->flow,
+                                  !skip_wildcards ? &ctx->xout->wc : NULL,
                                   table_id, &rule);
         ctx->xin->flow.in_port.ofp_port = old_in_port;
 
@@ -3077,7 +3078,8 @@ xlate_actions__(struct xlate_in *xin, struct xlate_out *xout)
     ctx.mpls_depth_delta = 0;
 
     if (!xin->ofpacts && !ctx.rule) {
-        rule_dpif_lookup(ctx.xbridge->ofproto, flow, wc, &rule);
+        rule_dpif_lookup(ctx.xbridge->ofproto, flow,
+                         !xin->skip_wildcards ? wc : NULL, &rule);
         if (ctx.xin->resubmit_stats) {
             rule_dpif_credit_stats(rule, ctx.xin->resubmit_stats);
         }
diff --git a/ofproto/ofproto-dpif-xlate.h b/ofproto/ofproto-dpif-xlate.h
index f4ef1e1..68076ca 100644
--- a/ofproto/ofproto-dpif-xlate.h
+++ b/ofproto/ofproto-dpif-xlate.h
@@ -73,6 +73,12 @@ struct xlate_in {
      * not if we are just revalidating. */
     bool may_learn;
 
+    /* If the caller of xlate_actions() doesn't need the flow_wildcards
+     * contained in struct xlate_out.  'skip_wildcards' can be set to true
+     * disabling the expensive wildcard computation.  When true, 'wc' in struct
+     * xlate_out is undefined and should not be read. */
+    bool skip_wildcards;
+
     /* The rule initiating translation or NULL. If both 'rule' and 'ofpacts'
      * are NULL, xlate_actions() will do the initial rule lookup itself. */
     struct rule_dpif *rule;
-- 
1.8.1.2




More information about the dev mailing list