perfmon: adding support for papi TMAM
[vpp.git] / src / plugins / perfmon / cli.c
index 7ffa6e8..1535570 100644 (file)
@@ -128,7 +128,9 @@ show_perfmon_bundle_command_fn (vlib_main_t *vm, unformat_input_t *input,
     vlib_cli_output (vm, "%U\n", format_perfmon_bundle, 0, 0);
 
   for (int i = 0; i < vec_len (vb); i++)
-    vlib_cli_output (vm, "%U\n", format_perfmon_bundle, vb[i], verbose);
+    /* bundle type will be unknown if no cpu_supports matched */
+    if (vb[i]->type != PERFMON_BUNDLE_TYPE_UNKNOWN)
+      vlib_cli_output (vm, "%U\n", format_perfmon_bundle, vb[i], verbose);
 
   vec_free (vb);
   return 0;
@@ -250,7 +252,6 @@ show_perfmon_active_bundle_command_fn (vlib_main_t *vm,
   perfmon_main_t *pm = &perfmon_main;
 
   vlib_cli_output (vm, "%U\n", format_perfmon_bundle, pm->active_bundle, 1);
-
   return 0;
 }
 
@@ -275,23 +276,15 @@ show_perfmon_stats_command_fn (vlib_main_t *vm, unformat_input_t *input,
   perfmon_instance_t *in;
   u8 *s = 0;
   int n_row = 0;
-  u8 raw = 0;
 
   if (b == 0)
-    return clib_error_return (0, "no budle selected");
-
-  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
-    {
-      if (unformat (input, "raw"))
-       raw = 1;
-      else
-       break;
-    }
+    return clib_error_return (0, "no bundle selected");
 
   n_instances = vec_len (it->instances);
   vec_validate (readings, n_instances - 1);
 
-  for (int i = 0; i < n_instances; i++)
+  /*Only perform read() for THREAD or SYSTEM bundles*/
+  for (int i = 0; i < n_instances && b->type != PERFMON_BUNDLE_TYPE_NODE; i++)
     {
       in = vec_elt_at_index (it->instances, i);
       r = vec_elt_at_index (readings, i);
@@ -313,13 +306,6 @@ show_perfmon_stats_command_fn (vlib_main_t *vm, unformat_input_t *input,
       char **hdr = b->column_headers;
       while (hdr[0])
        table_format_cell (t, -1, n_row++, "%s", hdr++[0]);
-
-      if (b->raw_column_headers && raw)
-       {
-         hdr = b->raw_column_headers;
-         while (hdr[0])
-           table_format_cell (t, -1, n_row++, "%s", hdr++[0]);
-       }
     }
 
   int col = 0;
@@ -327,7 +313,7 @@ show_perfmon_stats_command_fn (vlib_main_t *vm, unformat_input_t *input,
     {
       in = vec_elt_at_index (it->instances, i);
       r = vec_elt_at_index (readings, i);
-      table_format_cell (t, col, -1, "%s", in->name);
+      table_format_cell (t, col, -1, "%s", in->name, b->type);
       if (b->type == PERFMON_BUNDLE_TYPE_NODE)
        {
          perfmon_thread_runtime_t *tr;
@@ -337,18 +323,20 @@ show_perfmon_stats_command_fn (vlib_main_t *vm, unformat_input_t *input,
              {
                perfmon_node_stats_t ns;
                table_format_cell (t, ++col, -1, "%U", format_vlib_node_name,
-                                  vm, j);
+                                  vm, j, b->type);
                table_set_cell_align (t, col, -1, TTAA_RIGHT);
                table_set_cell_fg_color (t, col, -1, TTAC_CYAN);
                clib_memcpy_fast (&ns, tr->node_stats + j, sizeof (ns));
+
                for (int j = 0; j < n_row; j++)
-                 table_format_cell (t, col, j, "%U", b->format_fn, &ns, j);
+                 table_format_cell (t, col, j, "%U", b->format_fn, &ns, j,
+                                    b->type);
              }
        }
       else
        {
          for (int j = 0; j < n_row; j++)
-           table_format_cell (t, i, j, "%U", b->format_fn, r, j);
+           table_format_cell (t, i, j, "%U", b->format_fn, r, j, b->type);
        }
       col++;
     }
@@ -356,9 +344,6 @@ show_perfmon_stats_command_fn (vlib_main_t *vm, unformat_input_t *input,
   vlib_cli_output (vm, "%U\n", format_table, t);
   table_free (t);
 
-  if (raw)
-    vlib_cli_output (vm, "Sample time is %.4f seconds \n", pm->sample_time);
-
   if (b->footer)
     vlib_cli_output (vm, "\n%s\n", b->footer);
 
@@ -376,19 +361,37 @@ VLIB_CLI_COMMAND (show_perfmon_stats_command, static) = {
 };
 
 static clib_error_t *
-set_perfmon_bundle_command_fn (vlib_main_t *vm, unformat_input_t *input,
-                              vlib_cli_command_t *cmd)
+perfmon_reset_command_fn (vlib_main_t *vm, unformat_input_t *input,
+                         vlib_cli_command_t *cmd)
+{
+  perfmon_reset (vm);
+  return 0;
+}
+
+VLIB_CLI_COMMAND (perfmon_reset_command, static) = {
+  .path = "perfmon reset",
+  .short_help = "perfmon reset",
+  .function = perfmon_reset_command_fn,
+  .is_mp_safe = 1,
+};
+
+static clib_error_t *
+perfmon_start_command_fn (vlib_main_t *vm, unformat_input_t *input,
+                         vlib_cli_command_t *cmd)
 {
   perfmon_main_t *pm = &perfmon_main;
   unformat_input_t _line_input, *line_input = &_line_input;
   perfmon_bundle_t *b = 0;
 
+  if (pm->is_running)
+    return clib_error_return (0, "please stop first");
+
   if (unformat_user (input, unformat_line_input, line_input) == 0)
     return clib_error_return (0, "please specify bundle name");
 
   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
     {
-      if (unformat (line_input, "%U", unformat_perfmon_bundle_name, &b))
+      if (unformat (line_input, "bundle %U", unformat_perfmon_bundle_name, &b))
        ;
       else
        return clib_error_return (0, "unknown input '%U'",
@@ -399,44 +402,12 @@ set_perfmon_bundle_command_fn (vlib_main_t *vm, unformat_input_t *input,
   if (b == 0)
     return clib_error_return (0, "please specify bundle name");
 
-  if (pm->is_running)
-    return clib_error_return (0, "please stop first");
-
-  return perfmon_set (vm, b);
-}
-
-VLIB_CLI_COMMAND (set_perfmon_bundle_command, static) = {
-  .path = "set perfmon bundle",
-  .short_help = "set perfmon bundle [<bundle-name>]",
-  .function = set_perfmon_bundle_command_fn,
-  .is_mp_safe = 1,
-};
-
-static clib_error_t *
-perfmon_reset_command_fn (vlib_main_t *vm, unformat_input_t *input,
-                         vlib_cli_command_t *cmd)
-{
-  perfmon_reset (vm);
-  return 0;
-}
-
-VLIB_CLI_COMMAND (perfmon_reset_command, static) = {
-  .path = "perfmon reset",
-  .short_help = "perfmon reset",
-  .function = perfmon_reset_command_fn,
-  .is_mp_safe = 1,
-};
-
-static clib_error_t *
-perfmon_start_command_fn (vlib_main_t *vm, unformat_input_t *input,
-                         vlib_cli_command_t *cmd)
-{
-  return perfmon_start (vm);
+  return perfmon_start (vm, b);
 }
 
 VLIB_CLI_COMMAND (perfmon_start_command, static) = {
   .path = "perfmon start",
-  .short_help = "perfmon start",
+  .short_help = "perfmon start bundle [<bundle-name>]",
   .function = perfmon_start_command_fn,
   .is_mp_safe = 1,
 };