summaryrefslogtreecommitdiffstats
path: root/vlib/vlib/threads_cli.c
diff options
context:
space:
mode:
Diffstat (limited to 'vlib/vlib/threads_cli.c')
-rw-r--r--vlib/vlib/threads_cli.c161
1 files changed, 128 insertions, 33 deletions
diff --git a/vlib/vlib/threads_cli.c b/vlib/vlib/threads_cli.c
index 70bf729b306..aef67576751 100644
--- a/vlib/vlib/threads_cli.c
+++ b/vlib/vlib/threads_cli.c
@@ -157,28 +157,48 @@ static clib_error_t *
trace_frame_queue (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 = NULL;
frame_queue_trace_t *fqt;
frame_queue_nelt_counter_t *fqh;
vlib_thread_main_t *tm = vlib_get_thread_main ();
+ vlib_frame_queue_main_t *fqm;
u32 num_fq;
u32 fqix;
- u32 enable = 0;
+ u32 enable = 2;
+ u32 index = ~(u32) 0;
- if (unformat (input, "on"))
- {
- enable = 1;
- }
- else if (unformat (input, "off"))
- {
- enable = 0;
- }
- else
+ if (!unformat_user (input, unformat_line_input, line_input))
+ return 0;
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- return clib_error_return (0, "expecting on or off");
+ if (unformat (line_input, "on"))
+ enable = 1;
+ else if (unformat (line_input, "off"))
+ enable = 0;
+ else if (unformat (line_input, "index %u"), &index)
+ ;
+ else
+ return clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
}
- num_fq = vec_len (vlib_frame_queues);
+ unformat_free (line_input);
+
+ if (enable > 1)
+ return clib_error_return (0, "expecting on or off");
+
+ if (vec_len (tm->frame_queue_mains) == 0)
+ return clib_error_return (0, "no worker handoffs exist");
+
+ if (index > vec_len (tm->frame_queue_mains) - 1)
+ return clib_error_return (0,
+ "expecting valid worker handoff queue index");
+
+ fqm = vec_elt_at_index (tm->frame_queue_mains, index);
+
+ num_fq = vec_len (fqm->vlib_frame_queues);
if (num_fq == 0)
{
vlib_cli_output (vm, "No frame queues exist\n");
@@ -186,20 +206,20 @@ trace_frame_queue (vlib_main_t * vm, unformat_input_t * input,
}
// Allocate storage for trace if necessary
- vec_validate_aligned (tm->frame_queue_traces, num_fq - 1,
+ vec_validate_aligned (fqm->frame_queue_traces, num_fq - 1,
CLIB_CACHE_LINE_BYTES);
- vec_validate_aligned (tm->frame_queue_histogram, num_fq - 1,
+ vec_validate_aligned (fqm->frame_queue_histogram, num_fq - 1,
CLIB_CACHE_LINE_BYTES);
for (fqix = 0; fqix < num_fq; fqix++)
{
- fqt = &tm->frame_queue_traces[fqix];
- fqh = &tm->frame_queue_histogram[fqix];
+ fqt = &fqm->frame_queue_traces[fqix];
+ fqh = &fqm->frame_queue_histogram[fqix];
memset (fqt->n_vectors, 0xff, sizeof (fqt->n_vectors));
fqt->written = 0;
memset (fqh, 0, sizeof (*fqh));
- vlib_frame_queues[fqix]->trace = enable;
+ fqm->vlib_frame_queues[fqix]->trace = enable;
}
return error;
}
@@ -236,16 +256,16 @@ compute_percent (u64 * two_counters, u64 total)
* Display frame queue trace data gathered by threads.
*/
static clib_error_t *
-show_frame_queue_internal (vlib_main_t * vm, u32 histogram)
+show_frame_queue_internal (vlib_main_t * vm,
+ vlib_frame_queue_main_t * fqm, u32 histogram)
{
- vlib_thread_main_t *tm = vlib_get_thread_main ();
clib_error_t *error = NULL;
frame_queue_trace_t *fqt;
frame_queue_nelt_counter_t *fqh;
u32 num_fq;
u32 fqix;
- num_fq = vec_len (tm->frame_queue_traces);
+ num_fq = vec_len (fqm->frame_queue_traces);
if (num_fq == 0)
{
vlib_cli_output (vm, "No trace data for frame queues\n");
@@ -260,7 +280,7 @@ show_frame_queue_internal (vlib_main_t * vm, u32 histogram)
for (fqix = 0; fqix < num_fq; fqix++)
{
- fqt = &(tm->frame_queue_traces[fqix]);
+ fqt = &(fqm->frame_queue_traces[fqix]);
vlib_cli_output (vm, "Thread %d %v\n", fqix,
vlib_worker_threads[fqix].name);
@@ -273,7 +293,7 @@ show_frame_queue_internal (vlib_main_t * vm, u32 histogram)
if (histogram)
{
- fqh = &(tm->frame_queue_histogram[fqix]);
+ fqh = &(fqm->frame_queue_histogram[fqix]);
u32 nelt;
u64 total = 0;
@@ -350,14 +370,40 @@ static clib_error_t *
show_frame_queue_trace (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
- return show_frame_queue_internal (vm, 0);
+ vlib_thread_main_t *tm = vlib_get_thread_main ();
+ vlib_frame_queue_main_t *fqm;
+ clib_error_t *error;
+
+ vec_foreach (fqm, tm->frame_queue_mains)
+ {
+ vlib_cli_output (vm, "Worker handoff queue index %u (next node '%U'):",
+ fqm - tm->frame_queue_mains,
+ format_vlib_node_name, vm, fqm->node_index);
+ error = show_frame_queue_internal (vm, fqm, 0);
+ if (error)
+ return error;
+ }
+ return 0;
}
static clib_error_t *
show_frame_queue_histogram (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
- return show_frame_queue_internal (vm, 1);
+ vlib_thread_main_t *tm = vlib_get_thread_main ();
+ vlib_frame_queue_main_t *fqm;
+ clib_error_t *error;
+
+ vec_foreach (fqm, tm->frame_queue_mains)
+ {
+ vlib_cli_output (vm, "Worker handoff queue index %u (next node '%U'):",
+ fqm - tm->frame_queue_mains,
+ format_vlib_node_name, vm, fqm->node_index);
+ error = show_frame_queue_internal (vm, fqm, 1);
+ if (error)
+ return error;
+ }
+ return 0;
}
/* *INDENT-OFF* */
@@ -384,18 +430,43 @@ static clib_error_t *
test_frame_queue_nelts (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
+ unformat_input_t _line_input, *line_input = &_line_input;
+ vlib_thread_main_t *tm = vlib_get_thread_main ();
+ vlib_frame_queue_main_t *fqm;
clib_error_t *error = NULL;
u32 num_fq;
u32 fqix;
u32 nelts = 0;
+ u32 index = ~(u32) 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, "nelts %u"), &nelts)
+ ;
+ else if (unformat (line_input, "index %u"), &index)
+ ;
+ else
+ return clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ }
+
+ unformat_free (line_input);
+
+ if (index > vec_len (tm->frame_queue_mains) - 1)
+ return clib_error_return (0,
+ "expecting valid worker handoff queue index");
+
+ fqm = vec_elt_at_index (tm->frame_queue_mains, index);
- if ((unformat (input, "%d", &nelts) != 1) ||
- ((nelts != 4) && (nelts != 8) && (nelts != 16) && (nelts != 32)))
+ if ((nelts != 4) && (nelts != 8) && (nelts != 16) && (nelts != 32))
{
return clib_error_return (0, "expecting 4,8,16,32");
}
- num_fq = vec_len (vlib_frame_queues);
+ num_fq = vec_len (fqm->vlib_frame_queues);
if (num_fq == 0)
{
vlib_cli_output (vm, "No frame queues exist\n");
@@ -404,7 +475,7 @@ test_frame_queue_nelts (vlib_main_t * vm, unformat_input_t * input,
for (fqix = 0; fqix < num_fq; fqix++)
{
- vlib_frame_queues[fqix]->nelts = nelts;
+ fqm->vlib_frame_queues[fqix]->nelts = nelts;
}
return error;
@@ -426,15 +497,39 @@ static clib_error_t *
test_frame_queue_threshold (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
+ unformat_input_t _line_input, *line_input = &_line_input;
+ vlib_thread_main_t *tm = vlib_get_thread_main ();
+ vlib_frame_queue_main_t *fqm;
clib_error_t *error = NULL;
u32 num_fq;
u32 fqix;
- u32 threshold = 0;
+ u32 threshold = ~(u32) 0;
+ u32 index = ~(u32) 0;
+
+ if (!unformat_user (input, unformat_line_input, line_input))
+ return 0;
- if (unformat (input, "%d", &threshold))
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
+ if (unformat (line_input, "threshold %u"), &threshold)
+ ;
+ else if (unformat (line_input, "index %u"), &index)
+ ;
+ else
+ return clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
}
- else
+
+ unformat_free (line_input);
+
+ if (index > vec_len (tm->frame_queue_mains) - 1)
+ return clib_error_return (0,
+ "expecting valid worker handoff queue index");
+
+ fqm = vec_elt_at_index (tm->frame_queue_mains, index);
+
+
+ if (threshold == ~(u32) 0)
{
vlib_cli_output (vm, "expecting threshold value\n");
return error;
@@ -443,7 +538,7 @@ test_frame_queue_threshold (vlib_main_t * vm, unformat_input_t * input,
if (threshold == 0)
threshold = ~0;
- num_fq = vec_len (vlib_frame_queues);
+ num_fq = vec_len (fqm->vlib_frame_queues);
if (num_fq == 0)
{
vlib_cli_output (vm, "No frame queues exist\n");
@@ -452,7 +547,7 @@ test_frame_queue_threshold (vlib_main_t * vm, unformat_input_t * input,
for (fqix = 0; fqix < num_fq; fqix++)
{
- vlib_frame_queues[fqix]->vector_threshold = threshold;
+ fqm->vlib_frame_queues[fqix]->vector_threshold = threshold;
}
return error;