-/* Obtains statistic counters for 'rule' within 'p' and stores them into
- * '*packet_countp' and '*byte_countp'. The returned statistics include
- * statistics for all of 'rule''s facets. */
-static void
-query_stats(struct ofproto *p, struct rule *rule,
- uint64_t *packet_countp, uint64_t *byte_countp)
-{
- uint32_t keybuf[ODPUTIL_FLOW_KEY_U32S];
- uint64_t packet_count, byte_count;
- struct facet *facet;
- struct ofpbuf key;
-
- /* Start from historical data for 'rule' itself that are no longer tracked
- * by the datapath. This counts, for example, facets that have expired. */
- packet_count = rule->packet_count;
- byte_count = rule->byte_count;
-
- /* Ask the datapath for statistics on all of the rule's facets. (We could
- * batch up statistics requests using dpif_flow_get_multiple(), but that is
- * not yet implemented.)
- *
- * Also, add any statistics that are not tracked by the datapath for each
- * facet. This includes, for example, statistics for packets that were
- * executed "by hand" by ofproto via dpif_execute() but must be accounted
- * to a rule. */
- ofpbuf_use_stack(&key, keybuf, sizeof keybuf);
- LIST_FOR_EACH (facet, list_node, &rule->facets) {
- struct odp_flow odp_flow;
-
- ofpbuf_clear(&key);
- odp_flow_key_from_flow(&key, &facet->flow);
-
- odp_flow.key = key.data;
- odp_flow.key_len = key.size;
- odp_flow.actions = NULL;
- odp_flow.actions_len = 0;
- odp_flow.flags = 0;
- if (!dpif_flow_get(p->dpif, &odp_flow)) {
- packet_count += odp_flow.stats.n_packets;
- byte_count += odp_flow.stats.n_bytes;
- }
-
- packet_count += facet->packet_count;
- byte_count += facet->byte_count;
- }
-
- /* Return the stats to the caller. */
- *packet_countp = packet_count;
- *byte_countp = byte_count;
-}
-