static struct rule_dpif *rule_dpif_miss_rule(struct ofproto_dpif *ofproto,
const struct flow *flow);
+static void rule_get_stats(struct rule *, uint64_t *packets, uint64_t *bytes);
static void rule_credit_stats(struct rule_dpif *,
const struct dpif_flow_stats *);
-static void flow_push_stats(struct facet *, const struct dpif_flow_stats *);
static tag_type rule_calculate_tag(const struct flow *,
const struct minimask *, uint32_t basis);
static void rule_invalidate(const struct rule_dpif *);
uint64_t dp_byte_count; /* Last known byte count in the datapath. */
enum subfacet_path path; /* Installed in datapath? */
-
- /* Datapath port the packet arrived on. This is needed to remove
- * flows for ports that are no longer part of the bridge. Since the
- * flow definition only has the OpenFlow port number and the port is
- * no longer part of the bridge, we can't determine the datapath port
- * number needed to delete the flow from the datapath. */
- uint32_t odp_in_port;
};
#define SUBFACET_DESTROY_MAX_BATCH 50
struct subfacet **, int n);
static void subfacet_reset_dp_stats(struct subfacet *,
struct dpif_flow_stats *);
-static void subfacet_update_time(struct subfacet *, long long int used);
static void subfacet_update_stats(struct subfacet *,
const struct dpif_flow_stats *);
static int subfacet_install(struct subfacet *,
static void facet_flush_stats(struct facet *);
-static void facet_update_time(struct facet *, long long int used);
static void facet_reset_counters(struct facet *);
-static void facet_push_stats(struct facet *);
+static void facet_push_stats(struct facet *, bool may_learn);
static void facet_learn(struct facet *);
static void facet_account(struct facet *);
static void push_all_stats(void);
struct rule_dpif *miss_rule; /* Sends flow table misses to controller. */
struct rule_dpif *no_packet_in_rule; /* Drops flow table misses. */
- /* Statistics. */
- uint64_t n_matches;
-
/* Bridging. */
struct netflow *netflow;
struct dpif_sflow *sflow;
max_ports = dpif_get_max_ports(ofproto->backer->dpif);
ofproto_init_max_ports(ofproto_, MIN(max_ports, OFPP_MAX));
- ofproto->n_matches = 0;
-
ofproto->netflow = NULL;
ofproto->sflow = NULL;
ofproto->ipfix = NULL;
{
struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
struct dpif_dp_stats s;
+ uint64_t n_miss, n_no_pkt_in, n_bytes;
+ uint64_t n_lookup;
strcpy(ots->name, "classifier");
dpif_get_dp_stats(ofproto->backer->dpif, &s);
+ rule_get_stats(&ofproto->miss_rule->up, &n_miss, &n_bytes);
+ rule_get_stats(&ofproto->no_packet_in_rule->up, &n_no_pkt_in, &n_bytes);
- ots->lookup_count = htonll(s.n_hit + s.n_missed);
- ots->matched_count = htonll(s.n_hit + ofproto->n_matches);
+ n_lookup = s.n_hit + s.n_missed;
+ ots->lookup_count = htonll(n_lookup);
+ ots->matched_count = htonll(n_lookup - n_miss - n_no_pkt_in);
}
static struct ofport *
struct initial_vals initial_vals;
struct list packets;
enum dpif_upcall_type upcall_type;
- uint32_t odp_in_port;
};
struct flow_miss_op {
{
struct ofproto_dpif *ofproto = ofproto_dpif_cast(rule->up.ofproto);
- ofproto->n_matches++;
-
if (rule->up.cr.priority == FAIL_OPEN_PRIORITY) {
/*
* Extra-special case for fail-open mode.
miss->key = upcall->key;
miss->key_len = upcall->key_len;
miss->upcall_type = upcall->type;
- miss->odp_in_port = odp_in_port;
list_init(&miss->packets);
n_misses++;
const struct dpif_flow_stats *stats)
{
struct facet *facet = subfacet->facet;
+ struct dpif_flow_stats diff;
+
+ diff.tcp_flags = stats->tcp_flags;
+ diff.used = stats->used;
if (stats->n_packets >= subfacet->dp_packet_count) {
- uint64_t extra = stats->n_packets - subfacet->dp_packet_count;
- facet->packet_count += extra;
+ diff.n_packets = stats->n_packets - subfacet->dp_packet_count;
} else {
VLOG_WARN_RL(&rl, "unexpected packet count from the datapath");
+ diff.n_packets = 0;
}
if (stats->n_bytes >= subfacet->dp_byte_count) {
- facet->byte_count += stats->n_bytes - subfacet->dp_byte_count;
+ diff.n_bytes = stats->n_bytes - subfacet->dp_byte_count;
} else {
VLOG_WARN_RL(&rl, "unexpected byte count from datapath");
+ diff.n_bytes = 0;
}
subfacet->dp_packet_count = stats->n_packets;
subfacet->dp_byte_count = stats->n_bytes;
+ subfacet_update_stats(subfacet, &diff);
- facet->tcp_flags |= stats->tcp_flags;
-
- subfacet_update_time(subfacet, stats->used);
if (facet->accounted_bytes < facet->byte_count) {
facet_learn(facet);
facet_account(facet);
while (dpif_flow_dump_next(&dump, &key, &key_len, NULL, NULL, &stats)) {
struct flow flow;
struct subfacet *subfacet;
- struct ofport_dpif *ofport;
uint32_t key_hash;
if (ofproto_receive(backer, NULL, key, key_len, &flow, NULL, &ofproto,
ofproto->total_subfacet_count += hmap_count(&ofproto->subfacets);
ofproto->n_update_stats++;
- ofport = get_ofp_port(ofproto, flow.in_port);
- if (ofport && ofport->tnl_port) {
- netdev_vport_inc_rx(ofport->up.netdev, stats);
- }
-
key_hash = odp_flow_key_hash(key, key_len);
subfacet = subfacet_find(ofproto, key, key_len, key_hash);
switch (subfacet ? subfacet->path : SF_NOT_INSTALLED) {
static void
facet_learn(struct facet *facet)
{
- struct ofproto_dpif *ofproto = ofproto_dpif_cast(facet->rule->up.ofproto);
long long int now = time_msec();
- struct xlate_in xin;
if (!facet->xout.has_fin_timeout && now < facet->learn_rl) {
return;
return;
}
- xlate_in_init(&xin, ofproto, &facet->flow, &facet->initial_vals,
- facet->rule, facet->tcp_flags, NULL);
- xin.may_learn = true;
- xlate_actions_for_side_effects(&xin);
+ facet_push_stats(facet, true);
}
static void
ovs_assert(!subfacet->dp_packet_count);
}
- facet_push_stats(facet);
+ facet_push_stats(facet, false);
if (facet->accounted_bytes < facet->byte_count) {
facet_account(facet);
facet->accounted_bytes = facet->byte_count;
|| tag_set_intersects(&ofproto->backer->revalidate_set,
facet->xout.tags))
&& !facet_revalidate(facet)) {
- facet_revalidate(facet);
-
- /* facet_revalidate() may have destroyed 'facet'. */
- facet = facet_find(ofproto, flow, hash);
+ return NULL;
}
return facet;
return true;
}
-/* Updates 'facet''s used time. Caller is responsible for calling
- * facet_push_stats() to update the flows which 'facet' resubmits into. */
-static void
-facet_update_time(struct facet *facet, long long int used)
-{
- struct ofproto_dpif *ofproto = ofproto_dpif_cast(facet->rule->up.ofproto);
- if (used > facet->used) {
- facet->used = used;
- ofproto_rule_update_used(&facet->rule->up, used);
- netflow_flow_update_time(ofproto->netflow, &facet->nf_flow, used);
- }
-}
-
static void
facet_reset_counters(struct facet *facet)
{
}
static void
-facet_push_stats(struct facet *facet)
+facet_push_stats(struct facet *facet, bool may_learn)
{
struct dpif_flow_stats stats;
stats.n_packets = facet->packet_count - facet->prev_packet_count;
stats.n_bytes = facet->byte_count - facet->prev_byte_count;
stats.used = facet->used;
- stats.tcp_flags = 0;
+ stats.tcp_flags = facet->tcp_flags;
+
+ if (may_learn || stats.n_packets || facet->used > facet->prev_used) {
+ struct ofproto_dpif *ofproto =
+ ofproto_dpif_cast(facet->rule->up.ofproto);
+
+ struct ofport_dpif *in_port;
+ struct xlate_in xin;
- if (stats.n_packets || stats.n_bytes || facet->used > facet->prev_used) {
facet->prev_packet_count = facet->packet_count;
facet->prev_byte_count = facet->byte_count;
facet->prev_used = facet->used;
- rule_credit_stats(facet->rule, &stats);
- flow_push_stats(facet, &stats);
+ in_port = get_ofp_port(ofproto, facet->flow.in_port);
+ if (in_port && in_port->tnl_port) {
+ netdev_vport_inc_rx(in_port->up.netdev, &stats);
+ }
- update_mirror_stats(ofproto_dpif_cast(facet->rule->up.ofproto),
- facet->xout.mirrors, stats.n_packets,
+ rule_credit_stats(facet->rule, &stats);
+ netflow_flow_update_time(ofproto->netflow, &facet->nf_flow,
+ facet->used);
+ netflow_flow_update_flags(&facet->nf_flow, facet->tcp_flags);
+ update_mirror_stats(ofproto, facet->xout.mirrors, stats.n_packets,
stats.n_bytes);
+
+ xlate_in_init(&xin, ofproto, &facet->flow, &facet->initial_vals,
+ facet->rule, stats.tcp_flags, NULL);
+ xin.resubmit_stats = &stats;
+ xin.may_learn = may_learn;
+ xlate_actions_for_side_effects(&xin);
}
}
struct facet *facet;
HMAP_FOR_EACH (facet, hmap_node, &ofproto->facets) {
- facet_push_stats(facet);
+ facet_push_stats(facet, false);
if (run_fast) {
run_fast_rl();
}
rule->byte_count += stats->n_bytes;
ofproto_rule_update_used(&rule->up, stats->used);
}
-
-/* Pushes flow statistics to the rules which 'facet->flow' resubmits
- * into given 'facet->rule''s actions and mirrors. */
-static void
-flow_push_stats(struct facet *facet, const struct dpif_flow_stats *stats)
-{
- struct rule_dpif *rule = facet->rule;
- struct ofproto_dpif *ofproto = ofproto_dpif_cast(rule->up.ofproto);
- struct xlate_in xin;
-
- ofproto_rule_update_used(&rule->up, stats->used);
-
- xlate_in_init(&xin, ofproto, &facet->flow, &facet->initial_vals, rule,
- 0, NULL);
- xin.resubmit_stats = stats;
- xlate_actions_for_side_effects(&xin);
-}
\f
/* Subfacets. */
subfacet->dp_packet_count = 0;
subfacet->dp_byte_count = 0;
subfacet->path = SF_NOT_INSTALLED;
- subfacet->odp_in_port = miss->odp_in_port;
ofproto->subfacet_add_count++;
return subfacet;
subfacet->dp_byte_count = 0;
}
-/* Updates 'subfacet''s used time. The caller is responsible for calling
- * facet_push_stats() to update the flows which 'subfacet' resubmits into. */
-static void
-subfacet_update_time(struct subfacet *subfacet, long long int used)
-{
- if (used > subfacet->used) {
- subfacet->used = used;
- facet_update_time(subfacet->facet, used);
- }
-}
-
/* Folds the statistics from 'stats' into the counters in 'subfacet'.
*
* Because of the meaning of a subfacet's counters, it only makes sense to do
if (stats->n_packets || stats->used > subfacet->used) {
struct facet *facet = subfacet->facet;
- subfacet_update_time(subfacet, stats->used);
+ subfacet->used = MAX(subfacet->used, stats->used);
+ facet->used = MAX(facet->used, stats->used);
facet->packet_count += stats->n_packets;
facet->byte_count += stats->n_bytes;
facet->tcp_flags |= stats->tcp_flags;
- netflow_flow_update_flags(&facet->nf_flow, stats->tcp_flags);
}
}
\f