From 3f2079100ba9f7d24586dec4237c942e214cc571 Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Thu, 5 Dec 2013 13:09:27 -0800 Subject: [PATCH] ofproto-dpif-xlate: Add a mechanism to skip wildcard calculation. 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 Acked-by: Ben Pfaff --- ofproto/ofproto-dpif-xlate.c | 11 +++++++---- ofproto/ofproto-dpif-xlate.h | 6 ++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 402f54bcf..065560f9b 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -1873,9 +1873,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; @@ -1883,8 +1884,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; @@ -2886,6 +2887,7 @@ xlate_in_init(struct xlate_in *xin, struct ofproto_dpif *ofproto, xin->resubmit_hook = NULL; xin->report_hook = NULL; xin->resubmit_stats = NULL; + xin->skip_wildcards = false; } void @@ -3080,7 +3082,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 f4ef1e1fd..68076ca5f 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; -- 2.47.0