ofproto-dpif: Move tag_the_flow() to ofproto-dpif.c
authorEthan Jackson <ethan@nicira.com>
Sat, 22 Jun 2013 20:16:26 +0000 (13:16 -0700)
committerEthan Jackson <ethan@nicira.com>
Fri, 28 Jun 2013 01:23:40 +0000 (18:23 -0700)
This will help disentangle ofproto-dpif and ofproto-dpif-xlate.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto-dpif-xlate.c
ofproto/ofproto-dpif.c
ofproto/ofproto-dpif.h

index 8d72876..dedd723 100644 (file)
@@ -969,24 +969,6 @@ compose_output_action(struct xlate_ctx *ctx, ofp_port_t ofp_port)
     compose_output_action__(ctx, ofp_port, true);
 }
 
-static void
-tag_the_flow(struct xlate_ctx *ctx, struct rule_dpif *rule)
-{
-    struct ofproto_dpif *ofproto = ctx->ofproto;
-    uint8_t table_id = ctx->table_id;
-
-    if (table_id > 0 && table_id < N_TABLES) {
-        struct table_dpif *table = &ofproto->tables[table_id];
-        if (table->other_table) {
-            ctx->xout->tags |= (rule && rule->tag
-                                ? rule->tag
-                                : rule_calculate_tag(&ctx->xin->flow,
-                                                     &table->other_table->mask,
-                                                     table->basis));
-        }
-    }
-}
-
 /* Common rule processing in one place to avoid duplicating code. */
 static struct rule_dpif *
 ctx_rule_hooks(struct xlate_ctx *ctx, struct rule_dpif *rule,
@@ -1027,7 +1009,8 @@ xlate_table_action(struct xlate_ctx *ctx,
         rule = rule_dpif_lookup_in_table(ctx->ofproto, &ctx->xin->flow,
                                          &ctx->xout->wc, table_id);
 
-        tag_the_flow(ctx, rule);
+        ctx->xout->tags |= calculate_flow_tag(ctx->ofproto, &ctx->xin->flow,
+                                              ctx->table_id, rule);
 
         /* Restore the original input port.  Otherwise OFPP_NORMAL and
          * OFPP_IN_PORT will have surprising behavior. */
@@ -1744,7 +1727,8 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len,
             rule = rule_dpif_lookup_in_table(ctx->ofproto, flow, wc,
                                              ctx->table_id);
 
-            tag_the_flow(ctx, rule);
+            ctx->xout->tags = calculate_flow_tag(ctx->ofproto, &ctx->xin->flow,
+                                                 ctx->table_id, rule);
 
             rule = ctx_rule_hooks(ctx, rule, true);
 
index b6c1c83..e6f4ca3 100644 (file)
@@ -5502,6 +5502,22 @@ update_mirror_stats(struct ofproto_dpif *ofproto, mirror_mask_t mirrors,
     }
 }
 
+tag_type
+calculate_flow_tag(struct ofproto_dpif *ofproto, const struct flow *flow,
+                   uint8_t table_id, struct rule_dpif *rule)
+{
+    if (table_id > 0 && table_id < N_TABLES) {
+        struct table_dpif *table = &ofproto->tables[table_id];
+        if (table->other_table) {
+            return (rule && rule->tag
+                    ? rule->tag
+                    : rule_calculate_tag(flow, &table->other_table->mask,
+                                         table->basis));
+        }
+    }
+
+    return 0;
+}
 \f
 /* Optimized flow revalidation.
  *
index 511184a..493ee4c 100644 (file)
@@ -268,6 +268,7 @@ bool ofproto_dpif_dscp_from_priority(const struct ofport_dpif *,
                                      uint32_t priority, uint8_t *dscp);
 int ofproto_dpif_queue_to_priority(const struct ofproto_dpif *,
                                    uint32_t queue_id, uint32_t *priority);
-
+tag_type calculate_flow_tag(struct ofproto_dpif *, const struct flow *,
+                            uint8_t table_id, struct rule_dpif *);
 
 #endif /* ofproto-dpif.h */