aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-01-05 03:20:25 -0800
committerDave Barach <openvpp@barachs.net>2018-01-09 18:33:08 +0000
commite86a8edd3c14fb41ace2a12efd17bc7772bf623f (patch)
tree480219864cadd743fdb95c21379aeaf88a985e23 /src/vlib
parent4363ad6c96b5641fca1b16c5a6ec22e2364adcfd (diff)
api: refactor vlibmemory
- separate client/server code for both memory and socket apis - separate memory api code from generic vlib api code - move unix_shared_memory_fifo to svm and rename to svm_fifo_t - overall declutter Change-Id: I90cdd98ff74d0787d58825b914b0f1eafcfa4dc2 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/node.c54
-rw-r--r--src/vlib/node_funcs.h6
2 files changed, 60 insertions, 0 deletions
diff --git a/src/vlib/node.c b/src/vlib/node.c
index e6739dc7cf9..17dd2ea87d4 100644
--- a/src/vlib/node.c
+++ b/src/vlib/node.c
@@ -543,6 +543,60 @@ vlib_register_all_static_nodes (vlib_main_t * vm)
}
}
+vlib_node_t ***
+vlib_node_get_nodes (vlib_main_t * vm, u32 max_threads, int include_stats)
+{
+ vlib_node_main_t *nm = &vm->node_main;
+ vlib_node_t *n;
+ static vlib_node_t ***node_dups;
+ vlib_node_t **nodes;
+ static vlib_main_t **stat_vms;
+ vlib_main_t *stat_vm;
+ uword i, j;
+ u32 threads_to_serialize;
+
+ vec_reset_length (node_dups);
+
+ if (vec_len (stat_vms) == 0)
+ {
+ for (i = 0; i < vec_len (vlib_mains); i++)
+ {
+ stat_vm = vlib_mains[i];
+ if (stat_vm)
+ vec_add1 (stat_vms, stat_vm);
+ }
+ }
+
+ threads_to_serialize = clib_min (max_threads, vec_len (stat_vms));
+
+ /*
+ * Barrier sync across stats scraping.
+ * Otherwise, the counts will be grossly inaccurate.
+ */
+ vlib_worker_thread_barrier_sync (vm);
+
+ for (j = 0; j < threads_to_serialize; j++)
+ {
+ stat_vm = stat_vms[j];
+ nm = &stat_vm->node_main;
+
+ if (include_stats)
+ {
+ for (i = 0; i < vec_len (nm->nodes); i++)
+ {
+ n = nm->nodes[i];
+ vlib_node_sync_stats (stat_vm, n);
+ }
+ }
+
+ nodes = vec_dup (nm->nodes);
+ vec_add1 (node_dups, nodes);
+ }
+ vlib_worker_thread_barrier_release (vm);
+
+ return node_dups;
+}
+
clib_error_t *
vlib_node_main_init (vlib_main_t * vm)
{
diff --git a/src/vlib/node_funcs.h b/src/vlib/node_funcs.h
index 0734476cb8f..6607d31f67e 100644
--- a/src/vlib/node_funcs.h
+++ b/src/vlib/node_funcs.h
@@ -1122,6 +1122,12 @@ vlib_node_add_named_next (vlib_main_t * vm, uword node, char *name)
return vlib_node_add_named_next_with_slot (vm, node, name, ~0);
}
+/**
+ * Get list of nodes
+ */
+vlib_node_t ***vlib_node_get_nodes (vlib_main_t * vm, u32 max_threads,
+ int include_stats);
+
/* Query node given name. */
vlib_node_t *vlib_get_node_by_name (vlib_main_t * vm, u8 * name);