summaryrefslogtreecommitdiffstats
path: root/src/vlib/node_cli.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-03-26 13:06:13 +0100
committerDamjan Marion <damarion@cisco.com>2021-03-26 16:33:21 +0100
commit6ffb7c61899eb782416cbd2f117042a583f189f7 (patch)
treef6bd132d53b0aded6b235d13200dba2864afc7d8 /src/vlib/node_cli.c
parent83f13e45bcd4b1018aa29bb6f32324c32f3a11a8 (diff)
vlib: introduce vlib_get_main_by_index(), vlib_get_n_threads()
Type: improvement Change-Id: If3da7d4338470912f37ff1794620418d928fb77f Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/node_cli.c')
-rw-r--r--src/vlib/node_cli.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/vlib/node_cli.c b/src/vlib/node_cli.c
index 39fca6ea582..8cf57948cc4 100644
--- a/src/vlib/node_cli.c
+++ b/src/vlib/node_cli.c
@@ -210,14 +210,14 @@ show_node_graphviz (vlib_main_t * vm,
/* Updating the stats for multithreaded use cases.
* We need to dup the nodes to sum the stats from all threads.*/
nodes = vec_dup (nm->nodes);
- for (i = 1; i < vec_len (vlib_mains); i++)
+ for (i = 1; i < vlib_get_n_threads (); i++)
{
vlib_node_main_t *nm_clone;
vlib_main_t *vm_clone;
vlib_node_runtime_t *rt;
vlib_node_t *n;
- vm_clone = vlib_mains[i];
+ vm_clone = vlib_get_main_by_index (i);
nm_clone = &vm_clone->node_main;
for (j = 0; j < vec_len (nm_clone->nodes); j++)
@@ -516,9 +516,9 @@ show_node_runtime (vlib_main_t * vm,
|| unformat (input, "su"))
summary = 1;
- for (i = 0; i < vec_len (vlib_mains); i++)
+ for (i = 0; i < vlib_get_n_threads (); i++)
{
- stat_vm = vlib_mains[i];
+ stat_vm = vlib_get_main_by_index (i);
if (stat_vm)
vec_add1 (stat_vms, stat_vm);
}
@@ -592,7 +592,7 @@ show_node_runtime (vlib_main_t * vm,
}
}
- if (vec_len (vlib_mains) > 1)
+ if (vlib_get_n_threads () > 1)
{
vlib_worker_thread_t *w = vlib_worker_threads + j;
if (j > 0)
@@ -665,9 +665,9 @@ clear_node_runtime (vlib_main_t * vm,
vlib_main_t **stat_vms = 0, *stat_vm;
vlib_node_runtime_t *r;
- for (i = 0; i < vec_len (vlib_mains); i++)
+ for (i = 0; i < vlib_get_n_threads (); i++)
{
- stat_vm = vlib_mains[i];
+ stat_vm = vlib_get_main_by_index (i);
if (stat_vm)
vec_add1 (stat_vms, stat_vm);
}
@@ -848,10 +848,10 @@ show_node (vlib_main_t * vm, unformat_input_t * input,
s = format (s, "\n%8s %=12s %=12s %=12s %=12s %=12s\n", "Thread", "Calls",
"Clocks", "Vectors", "Max Clock", "Max Vectors");
- for (i = 0; i < vec_len (vlib_mains); i++)
+ for (i = 0; i < vlib_get_n_threads (); i++)
{
- n = vlib_get_node (vlib_mains[i], node_index);
- vlib_node_sync_stats (vlib_mains[i], n);
+ n = vlib_get_node (vlib_get_main_by_index (i), node_index);
+ vlib_node_sync_stats (vlib_get_main_by_index (i), n);
cl = n->stats_total.clocks - n->stats_last_clear.clocks;
ca = n->stats_total.calls - n->stats_last_clear.calls;