aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/tests/vnet/lisp-cp/test_cp_serdes.c1
-rw-r--r--src/tests/vnet/lisp-cp/test_lisp_types.c1
-rw-r--r--src/uri.am4
-rw-r--r--src/vlib-api.am39
-rw-r--r--src/vlibapi/node_unserialize.c227
-rw-r--r--src/vnet.am8
-rw-r--r--src/vpp-api-test.am1
-rw-r--r--src/vpp-api.am2
-rw-r--r--src/vpp-api/java/Makefile.am1
-rw-r--r--src/vpp.am4
10 files changed, 250 insertions, 38 deletions
diff --git a/src/tests/vnet/lisp-cp/test_cp_serdes.c b/src/tests/vnet/lisp-cp/test_cp_serdes.c
index 9d51dc8fa51..0c7d6fd0622 100644
--- a/src/tests/vnet/lisp-cp/test_cp_serdes.c
+++ b/src/tests/vnet/lisp-cp/test_cp_serdes.c
@@ -23,7 +23,6 @@
/* FIXME */
#include <vlibapi/api_helper_macros.h>
-vpe_api_main_t vpe_api_main;
#define _assert(e) \
error = CLIB_ERROR_ASSERT (e); \
diff --git a/src/tests/vnet/lisp-cp/test_lisp_types.c b/src/tests/vnet/lisp-cp/test_lisp_types.c
index 5d910f6669b..fa34a3c6200 100644
--- a/src/tests/vnet/lisp-cp/test_lisp_types.c
+++ b/src/tests/vnet/lisp-cp/test_lisp_types.c
@@ -20,7 +20,6 @@
/* FIXME */
#include <vlibapi/api_helper_macros.h>
-vpe_api_main_t vpe_api_main;
#define _assert(e) \
error = CLIB_ERROR_ASSERT (e); \
diff --git a/src/uri.am b/src/uri.am
index ad4d65d8580..ef5a2977871 100644
--- a/src/uri.am
+++ b/src/uri.am
@@ -14,11 +14,11 @@
noinst_PROGRAMS += uri_udp_test uri_tcp_test uri_socket_test
uri_udp_test_SOURCES = uri/uri_udp_test.c
-uri_udp_test_LDADD = libvlibmemoryclient.la libvlibapi.la libsvm.la \
+uri_udp_test_LDADD = libvlibmemoryclient.la libsvm.la \
libvppinfra.la -lpthread -lm -lrt
uri_tcp_test_SOURCES = uri/uri_tcp_test.c
-uri_tcp_test_LDADD = libvlibmemoryclient.la libvlibapi.la libsvm.la \
+uri_tcp_test_LDADD = libvlibmemoryclient.la libsvm.la \
libvppinfra.la -lpthread -lm -lrt
uri_socket_test_SOURCES = uri/uri_socket_test.c
diff --git a/src/vlib-api.am b/src/vlib-api.am
index b4616fe6cdb..eea52420b83 100644
--- a/src/vlib-api.am
+++ b/src/vlib-api.am
@@ -11,42 +11,41 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-lib_LTLIBRARIES += libvlibmemory.la libvlibapi.la libvlibmemoryclient.la \
+lib_LTLIBRARIES += libvlibmemory.la libvlibmemoryclient.la \
libvlibsocket.la
-libvlibmemory_la_DEPENDENCIES = libvppinfra.la libsvm.la
+libvlibmemory_la_DEPENDENCIES = libvppinfra.la libsvm.la libvlib.la
libvlibmemory_la_LIBADD = $(libvlibmemory_la_DEPENDENCIES) -lpthread
libvlibmemory_la_SOURCES = \
+ vlibapi/api.h \
+ vlibapi/api_helper_macros.h \
+ vlibapi/api_shared.c \
+ vlibapi/node_serialize.c \
vlibmemory/api.h \
vlibmemory/memclnt.api \
vlibmemory/memory_shared.c \
vlibmemory/memory_vlib.c \
- vlibmemory/vl_memory_api_h.h \
- vlibmemory/vl_memory_msg_enum.h \
vlibmemory/unix_shared_memory_queue.c \
- vlibmemory/unix_shared_memory_queue.h
-
-libvlibapi_la_DEPENDENCIES = libvppinfra.la
-libvlibapi_la_LIBADD = $(libvlibapi_la_DEPENDENCIES)
-libvlibapi_la_SOURCES = \
- vlibapi/api.h \
- vlibapi/api_helper_macros.h \
- vlibapi/api_shared.c \
- vlibapi/node_serialize.c
+ vlibmemory/unix_shared_memory_queue.h \
+ vlibmemory/vl_memory_api_h.h \
+ vlibmemory/vl_memory_msg_enum.h
nobase_include_HEADERS += vlibapi/api.h vlibapi/api_helper_macros.h vlibapi/vat_helper_macros.h
-libvlibmemoryclient_la_DEPENDENCIES = libvppinfra.la libsvm.la libvlibapi.la
+libvlibmemoryclient_la_DEPENDENCIES = libvppinfra.la libsvm.la
libvlibmemoryclient_la_LIBADD = $(libvlibmemoryclient_la_DEPENDENCIES) -lpthread
libvlibmemoryclient_la_SOURCES = \
+ vlibapi/api_helper_macros.h \
+ vlibapi/api_shared.c \
+ vlibapi/node_unserialize.c \
vlibmemory/api.h \
vlibmemory/memclnt.api \
- vlibmemory/memory_shared.c \
vlibmemory/memory_client.c \
- vlibmemory/vl_memory_api_h.h \
- vlibmemory/vl_memory_msg_enum.h \
+ vlibmemory/memory_shared.c \
vlibmemory/unix_shared_memory_queue.c \
- vlibmemory/unix_shared_memory_queue.h
+ vlibmemory/unix_shared_memory_queue.h \
+ vlibmemory/vl_memory_api_h.h \
+ vlibmemory/vl_memory_msg_enum.h
nobase_include_HEADERS += \
vlibmemory/api.h \
@@ -55,7 +54,7 @@ nobase_include_HEADERS += \
vlibmemory/unix_shared_memory_queue.h \
vlibmemory/memclnt.api.h
-libvlibsocket_la_DEPENDENCIES = libvppinfra.la libvlib.la libvlibmemory.la libvlibapi.la
+libvlibsocket_la_DEPENDENCIES = libvppinfra.la libvlib.la libvlibmemory.la
libvlibsocket_la_LIBADD = $(libvlibsocket_la_DEPENDENCIES)
libvlibsocket_la_SOURCES = \
vlibsocket/api.h \
@@ -71,7 +70,7 @@ nobase_include_HEADERS += \
vlibsocket/vl_socket_msg_enum.h \
vlibsocket/sockclnt.api.h
-BUILT_SOURCES += \
+BUILT_SOURCES += \
vlibsocket/sockclnt.api.h \
vlibmemory/memclnt.api.h \
vlibmemory/memclnt.api.json
diff --git a/src/vlibapi/node_unserialize.c b/src/vlibapi/node_unserialize.c
new file mode 100644
index 00000000000..bb0edfedda1
--- /dev/null
+++ b/src/vlibapi/node_unserialize.c
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <vlib/vlib.h>
+
+#include <vppinfra/serialize.h>
+
+/* serialized representation of state strings */
+
+#define foreach_state_string_code \
+_(STATE_DONE, "done") \
+_(STATE_DISABLED, "disabled") \
+_(STATE_TIME_WAIT, "time wait") \
+_(STATE_EVENT_WAIT, "event wait") \
+_(STATE_ANY_WAIT, "any wait") \
+_(STATE_POLLING, "polling") \
+_(STATE_INTERRUPT_WAIT, "interrupt wait") \
+_(STATE_INTERNAL, "internal")
+
+typedef enum
+{
+#define _(a,b) a,
+ foreach_state_string_code
+#undef _
+} state_string_enum_t;
+
+static char *state_strings[] = {
+#define _(a,b) b,
+ foreach_state_string_code
+#undef _
+};
+
+vlib_node_t ***
+vlib_node_unserialize (u8 * vector)
+{
+ serialize_main_t _sm, *sm = &_sm;
+ u32 nnodes, nnexts;
+ u32 nstat_vms;
+ vlib_node_t *node;
+ vlib_node_t **nodes;
+ vlib_node_t ***nodes_by_thread = 0;
+ int i, j, k;
+ u64 l, v, c, d;
+ state_string_enum_t state_code;
+ int stats_present;
+
+ serialize_open_vector (sm, vector);
+
+ nstat_vms = unserialize_likely_small_unsigned_integer (sm);
+
+ vec_validate (nodes_by_thread, nstat_vms - 1);
+ _vec_len (nodes_by_thread) = 0;
+
+ for (i = 0; i < nstat_vms; i++)
+ {
+ nnodes = unserialize_likely_small_unsigned_integer (sm);
+
+ nodes = 0;
+ vec_validate (nodes, nnodes - 1);
+ vec_add1 (nodes_by_thread, nodes);
+
+ for (j = 0; j < nnodes; j++)
+ {
+ node = 0;
+ vec_validate (node, 0);
+ nodes[j] = node;
+
+ unserialize_cstring (sm, (char **) &(node->name));
+ state_code = unserialize_likely_small_unsigned_integer (sm);
+ node->state_string = (u8 *) state_strings[state_code];
+
+ node->type = unserialize_likely_small_unsigned_integer (sm);
+ nnexts = unserialize_likely_small_unsigned_integer (sm);
+ if (nnexts > 0)
+ vec_validate (node->next_nodes, nnexts - 1);
+ for (k = 0; k < nnexts; k++)
+ node->next_nodes[k] =
+ unserialize_likely_small_unsigned_integer (sm);
+
+ stats_present = unserialize_likely_small_unsigned_integer (sm);
+
+ if (stats_present)
+ {
+ /* total clocks */
+ unserialize_integer (sm, &l, 8);
+ node->stats_total.clocks = l;
+ node->stats_last_clear.clocks = 0;
+
+ /* Total calls */
+ unserialize_integer (sm, &c, 8);
+ node->stats_total.calls = c;
+
+ /* Total vectors */
+ unserialize_integer (sm, &v, 8);
+ node->stats_total.vectors = v;
+
+ /* Total suspends */
+ unserialize_integer (sm, &d, 8);
+ node->stats_total.suspends = d;
+ }
+ }
+ }
+ return nodes_by_thread;
+}
+
+#if TEST_CODE
+
+static clib_error_t *
+test_node_serialize_command_fn (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ vlib_node_main_t *nm = &vm->node_main;
+ u8 *vector = 0;
+ vlib_node_t ***nodes_by_thread;
+ vlib_node_t **nodes;
+ vlib_node_t *node;
+ vlib_node_t *next_node;
+ int i, j, k;
+ u32 max_threads = (u32) ~ 0;
+ int include_nexts = 0;
+ int include_stats = 0;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "max-threads %d", &max_threads))
+ ;
+ else if (unformat (input, "stats"))
+ include_stats = 1;
+ else if (unformat (input, "nexts"))
+ include_nexts = 1;
+ else
+ break;
+ }
+
+ /*
+ * Keep the number of memcpy ops to a minimum (e.g. 1).
+ * The current size of the serialized vector is
+ * slightly under 4K.
+ */
+ vec_validate (vector, 16383);
+ vec_reset_length (vector);
+
+ vector = vlib_node_serialize (nm, vector, max_threads,
+ include_nexts, include_stats);
+
+ vlib_cli_output (vm, "result vector %d bytes", vec_len (vector));
+
+ nodes_by_thread = vlib_node_unserialize (vector);
+
+ vec_free (vector);
+
+ for (i = 0; i < vec_len (nodes_by_thread); i++)
+ {
+ nodes = nodes_by_thread[i];
+
+ vlib_cli_output (vm, "thread %d", i);
+
+ for (j = 0; j < vec_len (nodes); j++)
+ {
+ node = nodes[j];
+
+ vlib_cli_output (vm, "[%d] %s state %s", j, node->name,
+ node->state_string);
+
+ vlib_cli_output
+ (vm, " clocks %lld calls %lld suspends"
+ " %lld vectors %lld",
+ node->stats_total.clocks,
+ node->stats_total.calls,
+ node->stats_total.suspends, node->stats_total.vectors);
+
+ for (k = 0; k < vec_len (node->next_nodes); k++)
+ {
+ if (node->next_nodes[k] != ~0)
+ {
+ next_node = nodes[node->next_nodes[k]];
+ vlib_cli_output (vm, " [%d] %s", k, next_node->name);
+ }
+ }
+ }
+ }
+
+ for (j = 0; j < vec_len (nodes_by_thread); j++)
+ {
+ nodes = nodes_by_thread[j];
+
+ for (i = 0; i < vec_len (nodes); i++)
+ {
+ vec_free (nodes[i]->name);
+ vec_free (nodes[i]->next_nodes);
+ vec_free (nodes[i]);
+ }
+ vec_free (nodes);
+ }
+ vec_free (nodes_by_thread);
+
+ return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (test_node_serialize_node, static) = {
+ .path = "test node serialize",
+ .short_help = "test node serialize [max-threads NN] nexts stats",
+ .function = test_node_serialize_command_fn,
+};
+/* *INDENT-ON* */
+#endif
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet.am b/src/vnet.am
index 9c55e336d04..dcab19da866 100644
--- a/src/vnet.am
+++ b/src/vnet.am
@@ -19,9 +19,7 @@ libvnet_la_DEPENDENCIES = \
libvlib.la \
libsvmdb.la \
libsvm.la \
- libvlibapi.la \
- libvlibmemory.la \
- libvlibmemoryclient.la
+ libvlibmemory.la
libvnet_la_LIBADD = $(libvnet_la_DEPENDENCIES) -lm -lpthread -ldl -lrt
@@ -446,8 +444,7 @@ test_map_SOURCES = \
test_map_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_map_LDADD = libvnet.la libvppinfra.la libvlib.la \
- -lpthread -lvlibmemory -lvlibapi \
- -ldl -lsvm -lrt
+ -lpthread -lvlibmemory -ldl -lsvm -lrt
test_map_LDFLAGS = -static
endif
@@ -618,7 +615,6 @@ LDS = \
libvlib.la \
libsvm.la \
libsvmdb.la \
- libvlibapi.la \
libvlibmemory.la \
-lpthread -ldl -lrt -lm
diff --git a/src/vpp-api-test.am b/src/vpp-api-test.am
index d0df31a01c9..9465dc68f33 100644
--- a/src/vpp-api-test.am
+++ b/src/vpp-api-test.am
@@ -38,7 +38,6 @@ vpp_api_test_LDADD = \
libsvm.la \
libvatplugin.la \
libvppinfra.la \
- libvlibapi.la \
-lpthread -lm -lrt -ldl -lcrypto
vpp_api_test_LDFLAGS = -Wl,--export-dynamic
diff --git a/src/vpp-api.am b/src/vpp-api.am
index 0e05d60dddd..49e26da1460 100644
--- a/src/vpp-api.am
+++ b/src/vpp-api.am
@@ -19,7 +19,6 @@ libpneum_la_SOURCES = vpp-api/pneum/pneum.c
libpneum_la_LIBADD = \
$(top_builddir)/libvppinfra.la \
$(top_builddir)/libvlibmemoryclient.la \
- $(top_builddir)/libvlibapi.la \
$(top_builddir)/libsvm.la \
-lpthread -lm -lrt
@@ -37,7 +36,6 @@ test_pneum_SOURCES = vpp-api/pneum/pneum.c vpp-api/pneum/test_pneum.c
test_pneum_LDADD = \
$(top_builddir)/libvppinfra.la \
$(top_builddir)/libvlibmemoryclient.la \
- $(top_builddir)/libvlibapi.la \
$(top_builddir)/libsvm.la \
-lpthread -lm -lrt
endif
diff --git a/src/vpp-api/java/Makefile.am b/src/vpp-api/java/Makefile.am
index 6eb500847b2..f18e0c24f67 100644
--- a/src/vpp-api/java/Makefile.am
+++ b/src/vpp-api/java/Makefile.am
@@ -42,7 +42,6 @@ JVPP_LIBS = \
libjvpp_common.la \
$(top_builddir)/libvppinfra.la \
$(top_builddir)/libvlibmemoryclient.la \
- $(top_builddir)/libvlibapi.la \
$(top_builddir)/libsvm.la \
-lpthread -lm -lrt
diff --git a/src/vpp.am b/src/vpp.am
index 37466c60fdf..8cdc60d9440 100644
--- a/src/vpp.am
+++ b/src/vpp.am
@@ -71,7 +71,6 @@ VPP_VERSION = $(shell $(srcdir)/scripts/version)
fi
bin_vpp_LDADD = \
- libvlibapi.la \
libvlibmemory.la \
libvlib.la \
libvnet.la \
@@ -90,7 +89,6 @@ bin_test_client_SOURCES = \
bin_test_client_LDADD = \
libvlibmemoryclient.la \
- libvlibapi.la \
libsvm.la \
libvppinfra.la \
-lpthread -lm -lrt
@@ -103,7 +101,6 @@ bin_test_ha_SOURCES = \
bin_test_ha_LDADD = \
libvlibmemoryclient.la \
libvlibapi.la \
- libsvmdb.la \
libsvm.la \
libvppinfra.la \
-lpthread -lm -lrt
@@ -116,7 +113,6 @@ bin_summary_stats_client_SOURCES = \
bin_summary_stats_client_LDADD = \
libvlibmemoryclient.la \
- libvlibapi.la \
libsvm.la \
libvppinfra.la \
-lpthread -lm -lrt