Signed-off-by: Andy Zhou <az...@nicira.com> --- NEWS | 2 ++ lib/dpif-linux.c | 12 ++++++++++++ lib/dpif.h | 3 +++ utilities/ovs-dpctl.c | 8 ++++++++ 4 files changed, 25 insertions(+)
diff --git a/NEWS b/NEWS index 94e0da9..de473f0 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ Post-v2.0.0 IANA-assigned numbers in a future release. Consider updating your installations to specify port numbers instead of using the defaults. + - ovs-dpctl: + The "show" command also displays mega flow mask stats. v2.0.0 - xx xxx xxxx diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c index 6f75f57..0663b0a 100644 --- a/lib/dpif-linux.c +++ b/lib/dpif-linux.c @@ -74,6 +74,8 @@ struct dpif_linux_dp { const char *name; /* OVS_DP_ATTR_NAME. */ const uint32_t *upcall_pid; /* OVS_DP_UPCALL_PID. */ struct ovs_dp_stats stats; /* OVS_DP_ATTR_STATS. */ + struct ovs_dp_megaflow_stats + megaflow_stats; /* OVS_DP_ATTR_MEGAFLOW_STATS. */ }; static void dpif_linux_dp_init(struct dpif_linux_dp *); @@ -411,6 +413,8 @@ dpif_linux_get_stats(const struct dpif *dpif_, struct dpif_dp_stats *stats) stats->n_missed = dp.stats.n_missed; stats->n_lost = dp.stats.n_lost; stats->n_flows = dp.stats.n_flows; + stats->n_masks = dp.megaflow_stats.n_masks; + stats->n_mask_hit = dp.megaflow_stats.n_mask_hit; ofpbuf_delete(buf); } return error; @@ -1770,6 +1774,9 @@ dpif_linux_dp_from_ofpbuf(struct dpif_linux_dp *dp, const struct ofpbuf *buf) [OVS_DP_ATTR_NAME] = { .type = NL_A_STRING, .max_len = IFNAMSIZ }, [OVS_DP_ATTR_STATS] = { NL_POLICY_FOR(struct ovs_dp_stats), .optional = true }, + [OVS_DP_ATTR_MEGAFLOW_STATS] = { + NL_POLICY_FOR(struct ovs_dp_megaflow_stats), + .optional = true }, }; struct nlattr *a[ARRAY_SIZE(ovs_datapath_policy)]; @@ -1801,6 +1808,11 @@ dpif_linux_dp_from_ofpbuf(struct dpif_linux_dp *dp, const struct ofpbuf *buf) sizeof dp->stats); } + if (a[OVS_DP_ATTR_MEGAFLOW_STATS]) { + memcpy(&dp->megaflow_stats, nl_attr_get(a[OVS_DP_ATTR_MEGAFLOW_STATS]), + sizeof dp->megaflow_stats); + } + return 0; } diff --git a/lib/dpif.h b/lib/dpif.h index 8996c0a..ab69c1c 100644 --- a/lib/dpif.h +++ b/lib/dpif.h @@ -387,6 +387,9 @@ struct dpif_dp_stats { uint64_t n_missed; /* Number of flow table misses. */ uint64_t n_lost; /* Number of misses not sent to userspace. */ uint64_t n_flows; /* Number of flows present. */ + uint64_t n_masks; /* Number of mega flow masks. */ + uint64_t n_mask_hit; /* Number of mega flow masks visited for + flow table matches. */ }; int dpif_get_dp_stats(const struct dpif *, struct dpif_dp_stats *); diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c index 4fb02dd..c48f6e8 100644 --- a/utilities/ovs-dpctl.c +++ b/utilities/ovs-dpctl.c @@ -561,7 +561,15 @@ show_dpif(struct dpif *dpif) printf("\tlookups: hit:%"PRIu64" missed:%"PRIu64" lost:%"PRIu64"\n" "\tflows: %"PRIu64"\n", stats.n_hit, stats.n_missed, stats.n_lost, stats.n_flows); + if (stats.n_masks && stats.n_masks != UINT64_MAX) { + uint64_t n_pkts = stats.n_hit + stats.n_missed; + double avg = (double) stats.n_mask_hit / n_pkts; + + printf("\tmasks: hit:%"PRIu64" total:%"PRIu64" hit/pkt:%.2f\n", + stats.n_mask_hit, stats.n_masks, avg); + } } + DPIF_PORT_FOR_EACH (&dpif_port, &dump, dpif) { printf("\tport %u: %s", dpif_port.port_no, dpif_port.name); -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev