[ovs-dev,v6,7/7] dpif-netdev: Count sent packets and batches.

Message ID 1512143073-22347-8-git-send-email-i.maximets@samsung.com
State New
Delegated to: Ian Stokes
Headers show
Series
  • Output packet batching.
Related show

Commit Message

Ilya Maximets Dec. 1, 2017, 3:44 p.m.
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
 lib/dpif-netdev.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

Patch

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index da6b7b8..b2b651b 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -344,6 +344,8 @@  enum dp_stat_type {
     DP_STAT_LOST,               /* Packets not passed up to the client. */
     DP_STAT_LOOKUP_HIT,         /* Number of subtable lookups for flow table
                                    hits */
+    DP_STAT_SENT_PKTS,          /* Packets that has been sent. */
+    DP_STAT_SENT_BATCHES,       /* Number of batches sent. */
     DP_N_STATS
 };
 
@@ -515,6 +517,9 @@  struct dp_netdev_pmd_cycles {
     atomic_ullong n[PMD_N_CYCLES];
 };
 
+static void dp_netdev_count_packet(struct dp_netdev_pmd_thread *,
+                                   enum dp_stat_type type, int cnt);
+
 struct polled_queue {
     struct dp_netdev_rxq *rxq;
     odp_port_t port_no;
@@ -881,6 +886,7 @@  pmd_info_show_stats(struct ds *reply,
 {
     unsigned long long total_packets;
     uint64_t total_cycles = 0;
+    double lookups_per_hit = 0, packets_per_batch = 0;
     int i;
 
     /* These loops subtracts reference values ('*_zero') from the counters.
@@ -922,15 +928,23 @@  pmd_info_show_stats(struct ds *reply,
     }
     ds_put_cstr(reply, ":\n");
 
+    if (stats[DP_STAT_MASKED_HIT] > 0) {
+        lookups_per_hit = stats[DP_STAT_LOOKUP_HIT]
+                          / (double) stats[DP_STAT_MASKED_HIT];
+    }
+    if (stats[DP_STAT_SENT_BATCHES] > 0) {
+        packets_per_batch = stats[DP_STAT_SENT_PKTS]
+                            / (double) stats[DP_STAT_SENT_BATCHES];
+    }
+
     ds_put_format(reply,
                   "\temc hits:%llu\n\tmegaflow hits:%llu\n"
                   "\tavg. subtable lookups per hit:%.2f\n"
-                  "\tmiss:%llu\n\tlost:%llu\n",
+                  "\tmiss:%llu\n\tlost:%llu\n"
+                  "\tavg. packets per output batch: %.2f\n",
                   stats[DP_STAT_EXACT_HIT], stats[DP_STAT_MASKED_HIT],
-                  stats[DP_STAT_MASKED_HIT] > 0
-                  ? (1.0*stats[DP_STAT_LOOKUP_HIT])/stats[DP_STAT_MASKED_HIT]
-                  : 0,
-                  stats[DP_STAT_MISS], stats[DP_STAT_LOST]);
+                  lookups_per_hit, stats[DP_STAT_MISS], stats[DP_STAT_LOST],
+                  packets_per_batch);
 
     if (total_cycles == 0) {
         return;
@@ -3338,6 +3352,9 @@  dp_netdev_pmd_flush_output_on_port(struct dp_netdev_pmd_thread *pmd,
     ovs_assert(pmd->n_output_batches > 0);
     pmd->n_output_batches--;
 
+    dp_netdev_count_packet(pmd, DP_STAT_SENT_PKTS, output_cnt);
+    dp_netdev_count_packet(pmd, DP_STAT_SENT_BATCHES, 1);
+
     return output_cnt;
 }