-static clib_error_t *
-set_pmc_command_fn (vlib_main_t * vm,
- unformat_input_t * input, vlib_cli_command_t * cmd)
-{
- perfmon_main_t *pm = &perfmon_main;
- vlib_thread_main_t *vtm = vlib_get_thread_main ();
- int num_threads = 1 + vtm->n_threads;
- unformat_input_t _line_input, *line_input = &_line_input;
- perfmon_event_config_t ec;
- f64 delay;
- u32 timeout_seconds;
- u32 deadman;
- int last_set;
- clib_error_t *error;
-
- vec_reset_length (pm->single_events_to_collect);
- vec_reset_length (pm->paired_events_to_collect);
- pm->ipc_event_index = ~0;
- pm->mispredict_event_index = ~0;
-
- if (!unformat_user (input, unformat_line_input, line_input))
- return clib_error_return (0, "counter names required...");
-
- clib_bitmap_zero (pm->thread_bitmap);
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "timeout %u", &timeout_seconds))
- pm->timeout_interval = (f64) timeout_seconds;
- else if (unformat (line_input, "instructions-per-clock"))
- {
- ec.name = "instructions";
- ec.pe_type = PERF_TYPE_HARDWARE;
- ec.pe_config = PERF_COUNT_HW_INSTRUCTIONS;
- pm->ipc_event_index = vec_len (pm->paired_events_to_collect);
- vec_add1 (pm->paired_events_to_collect, ec);
- ec.name = "cpu-cycles";
- ec.pe_type = PERF_TYPE_HARDWARE;
- ec.pe_config = PERF_COUNT_HW_CPU_CYCLES;
- vec_add1 (pm->paired_events_to_collect, ec);
- }
- else if (unformat (line_input, "branch-mispredict-rate"))
- {
- ec.name = "branch-misses";
- ec.pe_type = PERF_TYPE_HARDWARE;
- ec.pe_config = PERF_COUNT_HW_BRANCH_MISSES;
- pm->mispredict_event_index = vec_len (pm->paired_events_to_collect);
- vec_add1 (pm->paired_events_to_collect, ec);
- ec.name = "branches";
- ec.pe_type = PERF_TYPE_HARDWARE;
- ec.pe_config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS;
- vec_add1 (pm->paired_events_to_collect, ec);
- }
- else if (unformat (line_input, "threads %U",
- unformat_bitmap_list, &pm->thread_bitmap))
- ;
- else if (unformat (line_input, "thread %U",
- unformat_bitmap_list, &pm->thread_bitmap))
- ;
- else if (unformat (line_input, "%U", unformat_processor_event, pm, &ec))