From: Ben Pfaff Date: Wed, 5 Oct 2011 18:18:13 +0000 (-0700) Subject: dpif: Avoid use of "struct ovs_dp_stats" in platform-independent modules. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8d9304d121f56af0e6f02677342933579be3277;p=openvswitch dpif: Avoid use of "struct ovs_dp_stats" in platform-independent modules. Over time we wish to reduce the number of datapath-protocol.h definitions used directly outside of Linux-specific code. This commit removes use of "struct ovs_dp_stats" from platform-independent code. Bug #7559. --- diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c index b195a721..4ddd4647 100644 --- a/lib/dpif-linux.c +++ b/lib/dpif-linux.c @@ -333,7 +333,7 @@ dpif_linux_wait(struct dpif *dpif OVS_UNUSED) } static int -dpif_linux_get_stats(const struct dpif *dpif_, struct ovs_dp_stats *stats) +dpif_linux_get_stats(const struct dpif *dpif_, struct dpif_dp_stats *stats) { struct dpif_linux_dp dp; struct ofpbuf *buf; @@ -341,7 +341,11 @@ dpif_linux_get_stats(const struct dpif *dpif_, struct ovs_dp_stats *stats) error = dpif_linux_dp_get(dpif_, &dp, &buf); if (!error) { - *stats = dp.stats; + stats->n_frags = dp.stats.n_frags; + stats->n_hit = dp.stats.n_hit; + stats->n_missed = dp.stats.n_missed; + stats->n_lost = dp.stats.n_lost; + stats->n_flows = dp.stats.n_flows; ofpbuf_delete(buf); } return error; diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 926464e2..af62bf0c 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -297,10 +297,9 @@ dpif_netdev_destroy(struct dpif *dpif) } static int -dpif_netdev_get_stats(const struct dpif *dpif, struct ovs_dp_stats *stats) +dpif_netdev_get_stats(const struct dpif *dpif, struct dpif_dp_stats *stats) { struct dp_netdev *dp = get_dp_netdev(dpif); - memset(stats, 0, sizeof *stats); stats->n_flows = hmap_count(&dp->flow_table); stats->n_frags = dp->n_frags; stats->n_hit = dp->n_hit; diff --git a/lib/dpif-provider.h b/lib/dpif-provider.h index 558b8913..1975cc5c 100644 --- a/lib/dpif-provider.h +++ b/lib/dpif-provider.h @@ -108,7 +108,7 @@ struct dpif_class { void (*wait)(struct dpif *dpif); /* Retrieves statistics for 'dpif' into 'stats'. */ - int (*get_stats)(const struct dpif *dpif, struct ovs_dp_stats *stats); + int (*get_stats)(const struct dpif *dpif, struct dpif_dp_stats *stats); /* Retrieves 'dpif''s current treatment of IP fragments into '*drop_frags': * true indicates that fragments are dropped, false indicates that diff --git a/lib/dpif.c b/lib/dpif.c index 82b60180..c6940b14 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -378,7 +378,7 @@ dpif_delete(struct dpif *dpif) /* Retrieves statistics for 'dpif' into 'stats'. Returns 0 if successful, * otherwise a positive errno value. */ int -dpif_get_dp_stats(const struct dpif *dpif, struct ovs_dp_stats *stats) +dpif_get_dp_stats(const struct dpif *dpif, struct dpif_dp_stats *stats) { int error = dpif->dpif_class->get_stats(dpif, stats); if (error) { diff --git a/lib/dpif.h b/lib/dpif.h index f8332194..04c0a519 100644 --- a/lib/dpif.h +++ b/lib/dpif.h @@ -59,7 +59,16 @@ const char *dpif_base_name(const struct dpif *); int dpif_delete(struct dpif *); -int dpif_get_dp_stats(const struct dpif *, struct ovs_dp_stats *); +/* Statisticss for a dpif as a whole. */ +struct dpif_dp_stats { + uint64_t n_frags; /* Number of dropped IP fragments. */ + uint64_t n_hit; /* Number of flow table matches. */ + 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. */ +}; +int dpif_get_dp_stats(const struct dpif *, struct dpif_dp_stats *); + int dpif_get_drop_frags(const struct dpif *, bool *drop_frags); int dpif_set_drop_frags(struct dpif *, bool drop_frags); diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index de243fcb..9e8b1fb5 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -710,7 +710,7 @@ static void get_tables(struct ofproto *ofproto_, struct ofp_table_stats *ots) { struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_); - struct ovs_dp_stats s; + struct dpif_dp_stats s; strcpy(ots->name, "classifier"); diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c index e724e745..4d0d3c2d 100644 --- a/utilities/ovs-dpctl.c +++ b/utilities/ovs-dpctl.c @@ -366,17 +366,17 @@ show_dpif(struct dpif *dpif) { struct dpif_port_dump dump; struct dpif_port dpif_port; - struct ovs_dp_stats stats; + struct dpif_dp_stats stats; struct netdev *netdev; printf("%s:\n", dpif_name(dpif)); if (!dpif_get_dp_stats(dpif, &stats)) { - printf("\tlookups: frags:%llu, hit:%llu, missed:%llu, lost:%llu\n", - (unsigned long long int) stats.n_frags, - (unsigned long long int) stats.n_hit, - (unsigned long long int) stats.n_missed, - (unsigned long long int) stats.n_lost); - printf("\tflows: %llu\n", (unsigned long long int)stats.n_flows); + printf("\tlookups: frags:%"PRIu64, stats.n_frags); + printf(" hit:%"PRIu64, stats.n_hit); + printf(" missed:%"PRIu64, stats.n_missed); + printf(" lost:%"PRIu64"\n", stats.n_lost); + + printf("\tflows: %"PRIu64"\n", stats.n_flows); } DPIF_PORT_FOR_EACH (&dpif_port, &dump, dpif) { printf("\tport %u: %s", dpif_port.port_no, dpif_port.name);