From: Ben Pfaff Date: Sat, 18 Aug 2012 06:27:39 +0000 (-0700) Subject: dpif: Add 'used' argument to dpif_flow_stats_extract(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7752d4ab7a6e7e9aaf83678b57790fc1c56ac83;p=openvswitch dpif: Add 'used' argument to dpif_flow_stats_extract(). The following commit will need to use a value other than a literal time_msec() in one case. This commit is just preparation. Factoring the time_msec() call out of the loop in handle_flow_miss_without_facet() is a really minor optimization. It isn't the main point here. Signed-off-by: Ben Pfaff --- diff --git a/lib/dpif.c b/lib/dpif.c index 667e07ce..29689667 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -685,15 +685,16 @@ dpif_port_poll_wait(const struct dpif *dpif) } /* Extracts the flow stats for a packet. The 'flow' and 'packet' - * arguments must have been initialized through a call to flow_extract(). */ + * arguments must have been initialized through a call to flow_extract(). + * 'used' is stored into stats->used. */ void dpif_flow_stats_extract(const struct flow *flow, const struct ofpbuf *packet, - struct dpif_flow_stats *stats) + long long int used, struct dpif_flow_stats *stats) { stats->tcp_flags = packet_get_tcp_flags(packet, flow); stats->n_bytes = packet->size; stats->n_packets = 1; - stats->used = time_msec(); + stats->used = used; } /* Appends a human-readable representation of 'stats' to 's'. */ diff --git a/lib/dpif.h b/lib/dpif.h index 02029150..45c78a55 100644 --- a/lib/dpif.h +++ b/lib/dpif.h @@ -129,7 +129,7 @@ struct dpif_flow_stats { }; void dpif_flow_stats_extract(const struct flow *, const struct ofpbuf *packet, - struct dpif_flow_stats *); + long long int used, struct dpif_flow_stats *); void dpif_flow_stats_format(const struct dpif_flow_stats *, struct ds *); enum dpif_flow_put_flags { diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 10d450ec..2fcb025e 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -2866,6 +2866,7 @@ handle_flow_miss_without_facet(struct flow_miss *miss, struct flow_miss_op *ops, size_t *n_ops) { struct ofproto_dpif *ofproto = ofproto_dpif_cast(rule->up.ofproto); + long long int now = time_msec(); struct action_xlate_ctx ctx; struct ofpbuf *packet; @@ -2878,7 +2879,7 @@ handle_flow_miss_without_facet(struct flow_miss *miss, ofpbuf_use_stub(&odp_actions, op->stub, sizeof op->stub); - dpif_flow_stats_extract(&miss->flow, packet, &stats); + dpif_flow_stats_extract(&miss->flow, packet, now, &stats); rule_credit_stats(rule, &stats); action_xlate_ctx_init(&ctx, ofproto, &miss->flow, miss->initial_tci, @@ -2929,7 +2930,7 @@ handle_flow_miss_with_facet(struct flow_miss *miss, struct facet *facet, subfacet_make_actions(subfacet, packet, &odp_actions); } - dpif_flow_stats_extract(&facet->flow, packet, &stats); + dpif_flow_stats_extract(&facet->flow, packet, time_msec(), &stats); subfacet_update_stats(subfacet, &stats); if (subfacet->actions_len) { @@ -4708,7 +4709,7 @@ rule_execute(struct rule *rule_, const struct flow *flow, uint64_t odp_actions_stub[1024 / 8]; struct ofpbuf odp_actions; - dpif_flow_stats_extract(flow, packet, &stats); + dpif_flow_stats_extract(flow, packet, time_msec(), &stats); rule_credit_stats(rule, &stats); ofpbuf_use_stub(&odp_actions, odp_actions_stub, sizeof odp_actions_stub); @@ -6434,7 +6435,7 @@ packet_out(struct ofproto *ofproto_, struct ofpbuf *packet, ofpbuf_use_stack(&key, &keybuf, sizeof keybuf); odp_flow_key_from_flow(&key, flow); - dpif_flow_stats_extract(flow, packet, &stats); + dpif_flow_stats_extract(flow, packet, time_msec(), &stats); action_xlate_ctx_init(&ctx, ofproto, flow, flow->vlan_tci, NULL, packet_get_tcp_flags(packet, flow), packet);