vlib api: move wrkr rpc flushing to vlib
[vpp.git] / src / vlib / node_cli.c
index 8cf5794..075430e 100644 (file)
@@ -42,6 +42,7 @@
 #include <fcntl.h>
 #include <vlib/vlib.h>
 #include <vlib/threads.h>
+#include <vlib/stats/stats.h>
 #include <math.h>
 
 static int
@@ -310,7 +311,7 @@ show_node_graphviz (vlib_main_t * vm,
 /*?
  * Dump dot files data to draw a graph of all the nodes.
  * If the argument 'filter' is provided, only the active nodes (since the last
- * "clear run" comand) are selected and they are scaled and colored according
+ * "clear run" command) are selected and they are scaled and colored according
  * to their utilization. You can choose to filter nodes that are called,
  * nodes that receive vectors or both (default).
  * The 'file' option allows to save data in a temp file.
@@ -465,13 +466,6 @@ format_vlib_node_stats (u8 * s, va_list * va)
   return s;
 }
 
-f64 vlib_get_stat_segment_update_rate (void) __attribute__ ((weak));
-f64
-vlib_get_stat_segment_update_rate (void)
-{
-  return 1e70;
-}
-
 static clib_error_t *
 show_node_runtime (vlib_main_t * vm,
                   unformat_input_t * input, vlib_cli_command_t * cmd)
@@ -498,7 +492,6 @@ show_node_runtime (vlib_main_t * vm,
       uword i, j;
       f64 dt;
       u64 n_input, n_output, n_drop, n_punt;
-      u64 n_internal_vectors, n_internal_calls;
       u64 n_clocks, l, v, c, d;
       int brief = 1;
       int summary = 0;
@@ -557,7 +550,6 @@ show_node_runtime (vlib_main_t * vm,
          vec_sort_with_function (nodes, node_cmp);
 
          n_input = n_output = n_drop = n_punt = n_clocks = 0;
-         n_internal_vectors = n_internal_calls = 0;
          for (i = 0; i < vec_len (nodes); i++)
            {
              n = nodes[i];
@@ -566,7 +558,6 @@ show_node_runtime (vlib_main_t * vm,
              n_clocks += l;
 
              v = n->stats_total.vectors - n->stats_last_clear.vectors;
-             c = n->stats_total.calls - n->stats_last_clear.calls;
 
              switch (n->type)
                {
@@ -577,11 +568,6 @@ show_node_runtime (vlib_main_t * vm,
                  n_output += (n->flags & VLIB_NODE_FLAG_IS_OUTPUT) ? v : 0;
                  n_drop += (n->flags & VLIB_NODE_FLAG_IS_DROP) ? v : 0;
                  n_punt += (n->flags & VLIB_NODE_FLAG_IS_PUNT) ? v : 0;
-                 if (!(n->flags & VLIB_NODE_FLAG_IS_OUTPUT))
-                   {
-                     n_internal_vectors += v;
-                     n_internal_calls += c;
-                   }
                  if (n->flags & VLIB_NODE_FLAG_IS_HANDOFF)
                    n_input += v;
                  break;
@@ -606,16 +592,14 @@ show_node_runtime (vlib_main_t * vm,
            }
 
          dt = time_now - nm->time_last_runtime_stats_clear;
-         vlib_cli_output
-           (vm,
-            "Time %.1f, %f sec internal node vector rate %.2f loops/sec %.2f\n"
-            "  vector rates in %.4e, out %.4e, drop %.4e, punt %.4e",
-            dt,
-            vlib_get_stat_segment_update_rate (),
-            internal_node_vector_rates[j],
-            stat_vm->loops_per_second,
-            (f64) n_input / dt,
-            (f64) n_output / dt, (f64) n_drop / dt, (f64) n_punt / dt);
+         vlib_cli_output (
+           vm,
+           "Time %.1f, %f sec internal node vector rate %.2f loops/sec %.2f\n"
+           "  vector rates in %.4e, out %.4e, drop %.4e, punt %.4e",
+           dt, vlib_stats_get_segment_update_rate (),
+           internal_node_vector_rates[j], stat_vm->loops_per_second,
+           (f64) n_input / dt, (f64) n_output / dt, (f64) n_drop / dt,
+           (f64) n_punt / dt);
 
          if (summary == 0)
            {
@@ -692,6 +676,8 @@ clear_node_runtime (vlib_main_t * vm,
       nm->time_last_runtime_stats_clear = vlib_time_now (vm);
     }
 
+  vlib_stats_set_timestamp (STAT_COUNTER_LAST_STATS_CLEAR,
+                           vm->node_main.time_last_runtime_stats_clear);
   vlib_worker_thread_barrier_release (vm);
 
   vec_free (stat_vms);