flow-hash: Add symmetric flag for flow hashing
[vpp.git] / src / vlib / node_cli.c
index 3dbf672..062854a 100644 (file)
@@ -148,19 +148,25 @@ format_vlib_node_stats (u8 * s, va_list * va)
   f64 maxc, maxcn;
   u32 maxn;
   u32 indent;
+  u64 pmc_ticks;
+  f64 pmc_ticks_per_packet;
 
   if (!n)
     {
       if (max)
-       return format (s,
-                      "%=30s%=17s%=16s%=16s%=16s%=16s",
-                      "Name", "Max Node Clocks", "Vectors at Max",
-                      "Max Clocks", "Avg Clocks", "Avg Vectors/Call");
+       s = format (s,
+                   "%=30s%=17s%=16s%=16s%=16s%=16s",
+                   "Name", "Max Node Clocks", "Vectors at Max",
+                   "Max Clocks", "Avg Clocks", "Avg Vectors/Call");
       else
-       return format (s,
-                      "%=30s%=12s%=16s%=16s%=16s%=16s%=16s",
-                      "Name", "State", "Calls", "Vectors", "Suspends",
-                      "Clocks", "Vectors/Call");
+       s = format (s,
+                   "%=30s%=12s%=16s%=16s%=16s%=16s%=16s",
+                   "Name", "State", "Calls", "Vectors", "Suspends",
+                   "Clocks", "Vectors/Call");
+      if (vm->perf_counter_id)
+       s = format (s, "%=16s", "Perf Ticks");
+
+      return s;
     }
 
   indent = format_get_indent (s);
@@ -176,6 +182,13 @@ format_vlib_node_stats (u8 * s, va_list * va)
   else
     maxcn = 0.0;
 
+  pmc_ticks = n->stats_total.perf_counter_ticks -
+    n->stats_last_clear.perf_counter_ticks;
+  if (p > 0)
+    pmc_ticks_per_packet = (f64) pmc_ticks / (f64) p;
+  else
+    pmc_ticks_per_packet = 0.0;
+
   /* Clocks per packet, per call or per suspend. */
   x = 0;
   if (p > 0)
@@ -208,6 +221,9 @@ format_vlib_node_stats (u8 * s, va_list * va)
     s = format (s, "%-30v%=12U%16Ld%16Ld%16Ld%16.2e%16.2f", ns,
                format_vlib_node_state, vm, n, c, p, d, x, v);
 
+  if (pmc_ticks_per_packet > 0.0)
+    s = format (s, "%16.2e", pmc_ticks_per_packet);
+
   if (ns != n->name)
     vec_free (ns);
 
@@ -345,9 +361,9 @@ show_node_runtime (vlib_main_t * vm,
              if (j > 0)
                vlib_cli_output (vm, "---------------");
 
-             if (w->lcore_id > -1)
+             if (w->cpu_id > -1)
                vlib_cli_output (vm, "Thread %d %s (lcore %u)", j, w->name,
-                                w->lcore_id);
+                                w->cpu_id);
              else
                vlib_cli_output (vm, "Thread %d %s", j, w->name);
            }
@@ -459,27 +475,37 @@ show_node (vlib_main_t * vm, unformat_input_t * input,
           vlib_cli_command_t * cmd)
 {
   unformat_input_t _line_input, *line_input = &_line_input;
+  clib_error_t *error = 0;
   vlib_node_main_t *nm = &vm->node_main;
   vlib_node_t *n;
   u8 *s = 0, *s2 = 0;
   u32 i, node_index = ~0;
   char *type_str;
+  u8 valid_node_name = 0;
 
   if (!unformat_user (input, unformat_line_input, line_input))
     return 0;
 
   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
     {
-      if (unformat (line_input, "%U", unformat_vlib_node, vm, &node_index))
-       ;
-      else if (unformat (line_input, "index %u", &node_index))
+      if (unformat (line_input, "index %u", &node_index))
        ;
       else
-       return clib_error_return (0, "unknown input '%U'",
-                                 format_unformat_error, line_input);
+       if (unformat (line_input, "%U", unformat_vlib_node, vm, &node_index))
+       valid_node_name = 1;
+      else if (!valid_node_name)
+       error = clib_error_return (0, "unknown node name: '%U'",
+                                  format_unformat_error, line_input);
+      else
+       error = clib_error_return (0, "unknown input '%U'",
+                                  format_unformat_error, line_input);
     }
+
   unformat_free (line_input);
 
+  if (error)
+    return error;
+
   if (node_index >= vec_len (vm->node_main.nodes))
     return clib_error_return (0, "please specify valid node");