dpif: Avoid use of "struct ovs_dp_stats" in platform-independent modules.
authorBen Pfaff <blp@nicira.com>
Wed, 5 Oct 2011 18:18:13 +0000 (11:18 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 5 Oct 2011 18:18:13 +0000 (11:18 -0700)
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.

lib/dpif-linux.c
lib/dpif-netdev.c
lib/dpif-provider.h
lib/dpif.c
lib/dpif.h
ofproto/ofproto-dpif.c
utilities/ovs-dpctl.c

index b195a72..4ddd464 100644 (file)
@@ -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;
index 926464e..af62bf0 100644 (file)
@@ -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;
index 558b891..1975cc5 100644 (file)
@@ -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
index 82b6018..c6940b1 100644 (file)
@@ -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) {
index f833219..04c0a51 100644 (file)
@@ -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);
 
index de243fc..9e8b1fb 100644 (file)
@@ -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");
 
index e724e74..4d0d3c2 100644 (file)
@@ -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);