#include <vlib/threads.h>
#include <vlib/unix/unix.h>
+#if DPDK==1
+#include <rte_config.h>
+#include <rte_common.h>
+#include <rte_eal.h>
+#include <rte_launch.h>
+#include <rte_lcore.h>
+#endif
+
static u8 *
format_sched_policy_and_priority (u8 * s, va_list * args)
{
line = format (line, "%-7u%-7u%-7u%", lcore, core_id, socket_id);
#if DPDK==1
+ ASSERT (lcore <= RTE_MAX_LCORE);
switch (lcore_config[lcore].state)
{
case WAIT:
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");
}
// 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;
}
* 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");
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);
if (histogram)
{
- fqh = &(tm->frame_queue_histogram[fqix]);
+ fqh = &(fqm->frame_queue_histogram[fqix]);
u32 nelt;
u64 total = 0;
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* */
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");
- if ((unformat (input, "%d", &nelts) != 1) ||
- ((nelts != 4) && (nelts != 8) && (nelts != 16) && (nelts != 32)))
+ fqm = vec_elt_at_index (tm->frame_queue_mains, index);
+
+ 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");
for (fqix = 0; fqix < num_fq; fqix++)
{
- vlib_frame_queues[fqix]->nelts = nelts;
+ fqm->vlib_frame_queues[fqix]->nelts = nelts;
}
return error;
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;
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");
for (fqix = 0; fqix < num_fq; fqix++)
{
- vlib_frame_queues[fqix]->vector_threshold = threshold;
+ fqm->vlib_frame_queues[fqix]->vector_threshold = threshold;
}
return error;