summaryrefslogtreecommitdiffstats
path: root/plugins/ioam-plugin/ioam/lib-trace
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2016-12-28 18:38:59 +0100
committerDamjan Marion <damarion@cisco.com>2017-01-01 18:11:43 +0100
commitcb034b9b374927c7552e36dcbc306d8456b2a0cb (patch)
tree9ff64f9792560630c8cf8faa2f74fc20671c30f1 /plugins/ioam-plugin/ioam/lib-trace
parentfdc62abdc113ea63dc867375bd49ef3043dcd290 (diff)
Move java,lua api and remaining plugins to src/
Change-Id: I1c3b87e886603678368428ae56a6bd3327cbc90d Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'plugins/ioam-plugin/ioam/lib-trace')
-rw-r--r--plugins/ioam-plugin/ioam/lib-trace/jvpp_ioam_trace.c124
-rw-r--r--plugins/ioam-plugin/ioam/lib-trace/jvpp_ioam_trace.h45
-rw-r--r--plugins/ioam-plugin/ioam/lib-trace/trace.api92
-rw-r--r--plugins/ioam-plugin/ioam/lib-trace/trace_all_api_h.h16
-rw-r--r--plugins/ioam-plugin/ioam/lib-trace/trace_api.c252
-rw-r--r--plugins/ioam-plugin/ioam/lib-trace/trace_msg_enum.h28
-rw-r--r--plugins/ioam-plugin/ioam/lib-trace/trace_test.c292
-rw-r--r--plugins/ioam-plugin/ioam/lib-trace/trace_util.c206
-rw-r--r--plugins/ioam-plugin/ioam/lib-trace/trace_util.h247
9 files changed, 0 insertions, 1302 deletions
diff --git a/plugins/ioam-plugin/ioam/lib-trace/jvpp_ioam_trace.c b/plugins/ioam-plugin/ioam/lib-trace/jvpp_ioam_trace.c
deleted file mode 100644
index 1d878ea3e24..00000000000
--- a/plugins/ioam-plugin/ioam/lib-trace/jvpp_ioam_trace.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * 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 <vnet/vnet.h>
-
-#include <ioam/lib-trace/trace_msg_enum.h>
-#define vl_typedefs /* define message structures */
-#include <ioam/lib-trace/trace_all_api_h.h>
-#undef vl_typedefs
-
-#define vl_endianfun
-#include <ioam/lib-trace/trace_all_api_h.h>
-#undef vl_endianfun
-
-#define vl_print(handle, ...)
-#define vl_printfun
-#include <ioam/lib-trace/trace_all_api_h.h>
-#undef vl_printfun
-
-/* Get the API version number */
-#define vl_api_version(n,v) static u32 api_version=(v);
-#include <ioam/lib-trace/trace_all_api_h.h>
-#undef vl_api_version
-
-#include <vnet/api_errno.h>
-#include <vlibapi/api.h>
-#include <vlibmemory/api.h>
-
-#if VPPJNI_DEBUG == 1
- #define DEBUG_LOG(...) clib_warning(__VA_ARGS__)
-#else
- #define DEBUG_LOG(...)
-#endif
-
-#include <jvpp-common/jvpp_common.h>
-
-#include "ioam/jvpp/io_fd_vpp_jvpp_ioamtrace_JVppIoamtraceImpl.h"
-#include "jvpp_ioam_trace.h"
-#include "ioam/jvpp/jvpp_ioam_trace_gen.h"
-
-/*
- * Class: io_fd_vpp_jvpp_ioamtrace_JVppIoamtraceImpl
- * Method: init0
- * Signature: (JI)V
- */
-JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_ioamtrace_JVppIoamtraceImpl_init0
- (JNIEnv *env, jclass clazz, jobject callback, jlong queue_address, jint my_client_index) {
- ioamtrace_main_t * plugin_main = &ioamtrace_main;
- u8 * name;
- clib_warning ("Java_io_fd_vpp_jvpp_ioamtrace_JVppIoamtraceImpl_init0");
-
- plugin_main->my_client_index = my_client_index;
- plugin_main->vl_input_queue = (unix_shared_memory_queue_t *)queue_address;
-
- name = format (0, "ioam_trace_%08x%c", api_version, 0);
- plugin_main->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
-
- if (plugin_main->msg_id_base == (u16) ~0) {
- jclass exClass = (*env)->FindClass(env, "java/lang/IllegalStateException");
- (*env)->ThrowNew(env, exClass, "ioam_trace plugin is not loaded in VPP");
- } else {
- plugin_main->callbackObject = (*env)->NewGlobalRef(env, callback);
- plugin_main->callbackClass = (jclass)(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, callback));
-
- #define _(N,n) \
- vl_msg_api_set_handlers(VL_API_##N + plugin_main->msg_id_base, #n, \
- vl_api_##n##_t_handler, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_api_reply_handler;
- #undef _
- }
-}
-
-JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_ioamtrace_JVppIoamtraceImpl_close0
-(JNIEnv *env, jclass clazz) {
- ioamtrace_main_t * plugin_main = &ioamtrace_main;
-
- // cleanup:
- (*env)->DeleteGlobalRef(env, plugin_main->callbackClass);
- (*env)->DeleteGlobalRef(env, plugin_main->callbackObject);
-
- plugin_main->callbackClass = NULL;
- plugin_main->callbackObject = NULL;
-}
-
-/* Attach thread to JVM and cache class references when initiating JVPP iOAM Trace */
-jint JNI_OnLoad(JavaVM *vm, void *reserved) {
- JNIEnv* env;
-
- if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_8) != JNI_OK) {
- return JNI_EVERSION;
- }
-
- if (cache_class_references(env) != 0) {
- clib_warning ("Failed to cache class references\n");
- return JNI_ERR;
- }
-
- return JNI_VERSION_1_8;
-}
-
-/* Clean up cached references when disposing JVPP iOAM Trace */
-void JNI_OnUnload(JavaVM *vm, void *reserved) {
- JNIEnv* env;
- if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_8) != JNI_OK) {
- return;
- }
- delete_class_references(env);
-}
diff --git a/plugins/ioam-plugin/ioam/lib-trace/jvpp_ioam_trace.h b/plugins/ioam-plugin/ioam/lib-trace/jvpp_ioam_trace.h
deleted file mode 100644
index 9fc16c15853..00000000000
--- a/plugins/ioam-plugin/ioam/lib-trace/jvpp_ioam_trace.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.
- */
-#ifndef __included_jvpp_ioam_trace_h__
-#define __included_jvpp_ioam_trace_h__
-
-#include <vnet/vnet.h>
-#include <vnet/ip/ip.h>
-#include <vnet/api_errno.h>
-#include <vlibapi/api.h>
-#include <vlibmemory/api.h>
-#include <jni.h>
-
-/* Global state for JVPP-IOAM-TRACE */
-typedef struct {
- /* Base message index for the trace plugin */
- u16 msg_id_base;
-
- /* Pointer to shared memory queue */
- unix_shared_memory_queue_t * vl_input_queue;
-
- /* VPP api client index */
- u32 my_client_index;
-
- /* Callback object and class references enabling asynchronous Java calls */
- jobject callbackObject;
- jclass callbackClass;
-
-} ioamtrace_main_t;
-
-ioamtrace_main_t ioamtrace_main __attribute__((aligned (64)));
-
-
-#endif /* __included_jvpp_ioam_trace_h__ */
diff --git a/plugins/ioam-plugin/ioam/lib-trace/trace.api b/plugins/ioam-plugin/ioam/lib-trace/trace.api
deleted file mode 100644
index cb9583256f6..00000000000
--- a/plugins/ioam-plugin/ioam/lib-trace/trace.api
+++ /dev/null
@@ -1,92 +0,0 @@
-/* Hey Emacs use -*- mode: C -*- */
-/*
- * 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.
- */
-
-
-/** \brief iOAM6 Trace - Set the iOAM6 trace profile
- @param trace_type - Type of trace requested
- @param num_elts - Number of trace elements to be inserted
- @param node_id - Trace Node ID
- @param trace_tsp- Timestamp resolution
- @param app_data - Application specific opaque
-*/
-define trace_profile_add {
- u32 client_index;
- u32 context;
- u8 trace_type;
- u8 num_elts;
- u8 trace_tsp;
- u32 node_id;
- u32 app_data;
-};
-
-/** \brief Trace profile add / del response
- @param context - sender context, to match reply w/ request
- @param retval - return value for request
-*/
-define trace_profile_add_reply {
- u32 context;
- i32 retval;
-};
-
-
-
-/** \brief Delete trace Profile
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
-*/
-define trace_profile_del {
- u32 client_index;
- u32 context;
-};
-
-/** \brief Trace profile add / del response
- @param context - sender context, to match reply w/ request
- @param retval - return value for request
-*/
-define trace_profile_del_reply {
- u32 context;
- i32 retval;
-};
-
-
-
-/** \brief Show trace Profile
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
-*/
-define trace_profile_show_config {
- u32 client_index;
- u32 context;
-};
-
-/** \brief Show trace config response
- @param context - sender context, to match reply w/ request
- @param retval - return value for request
- @param trace_type - Type of trace requested
- @param num_elts - Number of trace elements to be inserted
- @param node_id - Trace Node ID
- @param trace_tsp- Timestamp resolution
- @param app_data - Application specific opaque
-*/
-define trace_profile_show_config_reply {
- u32 context;
- i32 retval;
- u8 trace_type;
- u8 num_elts;
- u8 trace_tsp;
- u32 node_id;
- u32 app_data;
-};
diff --git a/plugins/ioam-plugin/ioam/lib-trace/trace_all_api_h.h b/plugins/ioam-plugin/ioam/lib-trace/trace_all_api_h.h
deleted file mode 100644
index 223f95450aa..00000000000
--- a/plugins/ioam-plugin/ioam/lib-trace/trace_all_api_h.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * 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 the generated file, see BUILT_SOURCES in Makefile.am */
-#include <ioam/lib-trace/trace.api.h>
diff --git a/plugins/ioam-plugin/ioam/lib-trace/trace_api.c b/plugins/ioam-plugin/ioam/lib-trace/trace_api.c
deleted file mode 100644
index 7e0d708e155..00000000000
--- a/plugins/ioam-plugin/ioam/lib-trace/trace_api.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * 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.
- */
-/*
- *------------------------------------------------------------------
- * trace_api.c - iOAM Trace related APIs to create
- * and maintain profiles
- *------------------------------------------------------------------
- */
-
-#include <vnet/vnet.h>
-#include <vnet/plugin/plugin.h>
-#include <ioam/lib-trace/trace_util.h>
-
-#include <vlibapi/api.h>
-#include <vlibmemory/api.h>
-#include <vlibsocket/api.h>
-
-/* define message IDs */
-#include <ioam/lib-trace/trace_msg_enum.h>
-
-/* define message structures */
-#define vl_typedefs
-#include <ioam/lib-trace/trace_all_api_h.h>
-#undef vl_typedefs
-
-/* define generated endian-swappers */
-#define vl_endianfun
-#include <ioam/lib-trace/trace_all_api_h.h>
-#undef vl_endianfun
-
-/* instantiate all the print functions we know about */
-#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
-#define vl_printfun
-#include <ioam/lib-trace/trace_all_api_h.h>
-#undef vl_printfun
-
-/* Get the API version number */
-#define vl_api_version(n,v) static u32 api_version=(v);
-#include <ioam/lib-trace/trace_all_api_h.h>
-#undef vl_api_version
-
-/*
- * A handy macro to set up a message reply.
- * Assumes that the following variables are available:
- * mp - pointer to request message
- * rmp - pointer to reply message type
- * rv - return value
- */
-
-#define TRACE_REPLY_MACRO(t) \
-do { \
- unix_shared_memory_queue_t * q = \
- vl_api_client_index_to_input_queue (mp->client_index); \
- if (!q) \
- return; \
- \
- rmp = vl_msg_api_alloc (sizeof (*rmp)); \
- rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \
- rmp->context = mp->context; \
- rmp->retval = ntohl(rv); \
- \
- vl_msg_api_send_shmem (q, (u8 *)&rmp); \
-} while(0);
-
-/* *INDENT-OFF* */
-#define TRACE_REPLY_MACRO2(t, body) \
-do { \
- unix_shared_memory_queue_t * q; \
- rv = vl_msg_api_pd_handler (mp, rv); \
- q = vl_api_client_index_to_input_queue (mp->client_index); \
- if (!q) \
- return; \
- \
- rmp = vl_msg_api_alloc (sizeof (*rmp)); \
- rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \
- rmp->context = mp->context; \
- rmp->retval = ntohl(rv); \
- do {body;} while (0); \
- vl_msg_api_send_shmem (q, (u8 *)&rmp); \
-} while(0);
-/* *INDENT-ON* */
-
-/* List of message types that this plugin understands */
-
-#define foreach_trace_plugin_api_msg \
-_(TRACE_PROFILE_ADD, trace_profile_add) \
-_(TRACE_PROFILE_DEL, trace_profile_del) \
-_(TRACE_PROFILE_SHOW_CONFIG, trace_profile_show_config)
-
-static void vl_api_trace_profile_add_t_handler
- (vl_api_trace_profile_add_t * mp)
-{
- trace_main_t *sm = &trace_main;
- int rv = 0;
- vl_api_trace_profile_add_reply_t *rmp;
- trace_profile *profile = NULL;
-
- profile = trace_profile_find ();
- if (profile)
- {
- rv =
- trace_profile_create (profile, mp->trace_type, mp->num_elts,
- mp->trace_tsp, ntohl (mp->node_id),
- ntohl (mp->app_data));
- if (rv != 0)
- goto ERROROUT;
- }
- else
- {
- rv = -3;
- }
-ERROROUT:
- TRACE_REPLY_MACRO (VL_API_TRACE_PROFILE_ADD_REPLY);
-}
-
-
-static void vl_api_trace_profile_del_t_handler
- (vl_api_trace_profile_del_t * mp)
-{
- trace_main_t *sm = &trace_main;
- int rv = 0;
- vl_api_trace_profile_del_reply_t *rmp;
-
- clear_trace_profiles ();
-
- TRACE_REPLY_MACRO (VL_API_TRACE_PROFILE_DEL_REPLY);
-}
-
-static void vl_api_trace_profile_show_config_t_handler
- (vl_api_trace_profile_show_config_t * mp)
-{
- trace_main_t *sm = &trace_main;
- vl_api_trace_profile_show_config_reply_t *rmp;
- int rv = 0;
- trace_profile *profile = trace_profile_find ();
- if (profile->valid)
- {
- TRACE_REPLY_MACRO2 (VL_API_TRACE_PROFILE_SHOW_CONFIG_REPLY,
- rmp->trace_type = profile->trace_type;
- rmp->num_elts = profile->num_elts;
- rmp->trace_tsp = profile->trace_tsp;
- rmp->node_id = htonl (profile->node_id);
- rmp->app_data = htonl (profile->app_data);
- );
- }
- else
- {
- TRACE_REPLY_MACRO2 (VL_API_TRACE_PROFILE_SHOW_CONFIG_REPLY,
- rmp->trace_type = 0;
- rmp->num_elts = 0; rmp->trace_tsp = 0;
- rmp->node_id = 0; rmp->app_data = 0;
- );
- }
-}
-
-/*
- * This routine exists to convince the vlib plugin framework that
- * we haven't accidentally copied a random .dll into the plugin directory.
- *
- * Also collects global variable pointers passed from the vpp engine
- */
-
-clib_error_t *
-vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h,
- int from_early_init)
-{
- trace_main_t *sm = &trace_main;
- clib_error_t *error = 0;
-
- sm->vlib_main = vm;
- sm->vnet_main = h->vnet_main;
- return error;
-}
-
-/* Set up the API message handling tables */
-static clib_error_t *
-trace_plugin_api_hookup (vlib_main_t * vm)
-{
- trace_main_t *sm = &trace_main;
-#define _(N,n) \
- vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \
- #n, \
- vl_api_##n##_t_handler, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_trace_plugin_api_msg;
-#undef _
-
- return 0;
-}
-
-#define vl_msg_name_crc_list
-#include <ioam/lib-trace/trace_all_api_h.h>
-#undef vl_msg_name_crc_list
-
-static void
-setup_message_id_table (trace_main_t * sm, api_main_t * am)
-{
-#define _(id,n,crc) \
- vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base);
- foreach_vl_msg_name_crc_trace;
-#undef _
-}
-
-static clib_error_t *
-trace_init (vlib_main_t * vm)
-{
- trace_main_t *sm = &trace_main;
- clib_error_t *error = 0;
- u8 *name;
-
- bzero (sm, sizeof (trace_main));
- (void) trace_util_init ();
- name = format (0, "ioam_trace_%08x%c", api_version, 0);
-
- /* Ask for a correctly-sized block of API message decode slots */
- sm->msg_id_base = vl_msg_api_get_msg_ids
- ((char *) name, VL_MSG_FIRST_AVAILABLE);
-
- error = trace_plugin_api_hookup (vm);
-
- /* Add our API messages to the global name_crc hash table */
- setup_message_id_table (sm, &api_main);
-
- vec_free (name);
-
- return error;
-}
-
-VLIB_INIT_FUNCTION (trace_init);
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/plugins/ioam-plugin/ioam/lib-trace/trace_msg_enum.h b/plugins/ioam-plugin/ioam/lib-trace/trace_msg_enum.h
deleted file mode 100644
index 78c35665f3c..00000000000
--- a/plugins/ioam-plugin/ioam/lib-trace/trace_msg_enum.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-#ifndef included_trace_msg_enum_h
-#define included_trace_msg_enum_h
-
-#include <vppinfra/byte_order.h>
-
-#define vl_msg_id(n,h) n,
-typedef enum {
-#include <ioam/lib-trace/trace_all_api_h.h>
- /* We'll want to know how many messages IDs we need... */
- VL_MSG_FIRST_AVAILABLE,
-} vl_msg_id_t;
-#undef vl_msg_id
-
-#endif /* included_trace_msg_enum_h */
diff --git a/plugins/ioam-plugin/ioam/lib-trace/trace_test.c b/plugins/ioam-plugin/ioam/lib-trace/trace_test.c
deleted file mode 100644
index 111dd461b5b..00000000000
--- a/plugins/ioam-plugin/ioam/lib-trace/trace_test.c
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * 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.
- */
-/*
- *------------------------------------------------------------------
- * trace_test.c - test harness for trace plugin
- *------------------------------------------------------------------
- */
-
-#include <vat/vat.h>
-#include <vlibapi/api.h>
-#include <vlibmemory/api.h>
-#include <vlibsocket/api.h>
-#include <vppinfra/error.h>
-
-/* Declare message IDs */
-#include <ioam/lib-trace/trace_msg_enum.h>
-
-/* define message structures */
-#define vl_typedefs
-#include <ioam/lib-trace/trace_all_api_h.h>
-#undef vl_typedefs
-
-/* declare message handlers for each api */
-
-#define vl_endianfun /* define message structures */
-#include <ioam/lib-trace/trace_all_api_h.h>
-#undef vl_endianfun
-
-/* instantiate all the print functions we know about */
-#define vl_print(handle, ...)
-#define vl_printfun
-#include <ioam/lib-trace/trace_all_api_h.h>
-#undef vl_printfun
-
-/* Get the API version number. */
-#define vl_api_version(n,v) static u32 api_version=(v);
-#include <ioam/lib-trace/trace_all_api_h.h>
-#undef vl_api_version
-
-
-typedef struct
-{
- /* API message ID base */
- u16 msg_id_base;
- vat_main_t *vat_main;
-} trace_test_main_t;
-
-trace_test_main_t trace_test_main;
-
-#define foreach_standard_reply_retval_handler \
-_(trace_profile_add_reply) \
-_(trace_profile_del_reply)
-
-#define foreach_custom_reply_handler \
-_(trace_profile_show_config_reply, \
- if(mp->trace_type) \
- { \
- errmsg(" Trace Type : 0x%x (%d)\n",mp->trace_type, mp->trace_type); \
- errmsg(" Trace timestamp precision : %d \n",mp->trace_tsp); \
- errmsg(" Node Id : 0x%x (%d)\n",htonl(mp->node_id), htonl(mp->node_id)); \
- errmsg(" App Data : 0x%x (%d)\n",htonl(mp->app_data), htonl(mp->app_data)); \
- } \
- else errmsg("No valid trace profile configuration found\n");)
-#define _(n) \
- static void vl_api_##n##_t_handler \
- (vl_api_##n##_t * mp) \
- { \
- vat_main_t * vam = trace_test_main.vat_main; \
- i32 retval = ntohl(mp->retval); \
- if (vam->async_mode) { \
- vam->async_errors += (retval < 0); \
- } else { \
- vam->retval = retval; \
- vam->result_ready = 1; \
- } \
- }
-foreach_standard_reply_retval_handler;
-#undef _
-
-#define _(n,body) \
- static void vl_api_##n##_t_handler \
- (vl_api_##n##_t * mp) \
- { \
- vat_main_t * vam = trace_test_main.vat_main; \
- i32 retval = ntohl(mp->retval); \
- if (vam->async_mode) { \
- vam->async_errors += (retval < 0); \
- } else { \
- vam->retval = retval; \
- vam->result_ready = 1; \
- } \
- if(retval>=0)do{body;} while(0); \
- else errmsg("Error, retval: %d",retval); \
- }
-foreach_custom_reply_handler;
-#undef _
-/*
- * Table of message reply handlers, must include boilerplate handlers
- * we just generated
- */
-#define foreach_vpe_api_reply_msg \
-_(TRACE_PROFILE_ADD_REPLY, trace_profile_add_reply) \
-_(TRACE_PROFILE_DEL_REPLY, trace_profile_del_reply) \
-_(TRACE_PROFILE_SHOW_CONFIG_REPLY, trace_profile_show_config_reply)
-
-
-/* M: construct, but don't yet send a message */
-
-#define M(T,t) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-#define M2(T,t,n) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-/* S: send a message */
-#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
-
-/* W: wait for results, with timeout */
-#define W \
-do { \
- timeout = vat_time_now (vam) + 1.0; \
- \
- while (vat_time_now (vam) < timeout) { \
- if (vam->result_ready == 1) { \
- return (vam->retval); \
- } \
- } \
- return -99; \
-} while(0);
-
-
-static int
-api_trace_profile_add (vat_main_t * vam)
-{
- trace_test_main_t *sm = &trace_test_main;
- unformat_input_t *input = vam->input;
- vl_api_trace_profile_add_t *mp;
- u8 trace_type = 0;
- u8 num_elts = 0;
- int rv = 0;
- u32 node_id = 0;
- u32 app_data = 0;
- u8 trace_tsp = 0;
- f64 timeout;
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "trace-type 0x%x", &trace_type))
- ;
- else if (unformat (input, "trace-elts %d", &num_elts))
- ;
- else if (unformat (input, "trace-tsp %d", &trace_tsp))
- ;
- else if (unformat (input, "node-id 0x%x", &node_id))
- ;
- else if (unformat (input, "app-data 0x%x", &app_data))
- ;
-
- else
- break;
- }
-
-
- M (TRACE_PROFILE_ADD, trace_profile_add);
-
- mp->trace_type = trace_type;
- mp->trace_tsp = trace_tsp;
- mp->node_id = htonl (node_id);
- mp->app_data = htonl (app_data);
- mp->num_elts = num_elts;
-
- S;
- W;
-
- return (rv);
-}
-
-
-
-static int
-api_trace_profile_del (vat_main_t * vam)
-{
- trace_test_main_t *sm = &trace_test_main;
- vl_api_trace_profile_del_t *mp;
- f64 timeout;
-
- M (TRACE_PROFILE_DEL, trace_profile_del);
- S;
- W;
- return 0;
-}
-
-static int
-api_trace_profile_show_config (vat_main_t * vam)
-{
- trace_test_main_t *sm = &trace_test_main;
- vl_api_trace_profile_show_config_t *mp;
- f64 timeout;
- M (TRACE_PROFILE_SHOW_CONFIG, trace_profile_show_config);
- S;
- W;
- return 0;
-}
-
-/*
- * List of messages that the api test plugin sends,
- * and that the data plane plugin processes
- */
-#define foreach_vpe_api_msg \
-_(trace_profile_add, ""\
- "trace-type <0x1f|0x3|0x9|0x11|0x19> trace-elts <nn> trace-tsp <0|1|2|3> node-id <node id in hex> app-data <app_data in hex>") \
-_(trace_profile_del, "[id <nn>]") \
-_(trace_profile_show_config, "[id <nn>]")
-
-
-void
-vat_api_hookup (vat_main_t * vam)
-{
- trace_test_main_t *sm = &trace_test_main;
- /* Hook up handlers for replies from the data plane plug-in */
-#define _(N,n) \
- vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \
- #n, \
- vl_api_##n##_t_handler, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_vpe_api_reply_msg;
-#undef _
-
- /* API messages we can send */
-#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
- foreach_vpe_api_msg;
-#undef _
-
- /* Help strings */
-#define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
- foreach_vpe_api_msg;
-#undef _
-}
-
-clib_error_t *
-vat_plugin_register (vat_main_t * vam)
-{
- trace_test_main_t *sm = &trace_test_main;
- u8 *name;
-
- sm->vat_main = vam;
-
- name = format (0, "ioam_trace_%08x%c", api_version, 0);
- sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
-
- if (sm->msg_id_base != (u16) ~ 0)
- vat_api_hookup (vam);
-
- vec_free (name);
-
- return 0;
-}
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/plugins/ioam-plugin/ioam/lib-trace/trace_util.c b/plugins/ioam-plugin/ioam/lib-trace/trace_util.c
deleted file mode 100644
index 5c7f1eefd9c..00000000000
--- a/plugins/ioam-plugin/ioam/lib-trace/trace_util.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * 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 <vnet/vnet.h>
-#include <stdint.h>
-#include <time.h>
-#include <string.h>
-#include <vppinfra/mem.h>
-#include "trace_util.h"
-
-trace_main_t trace_main;
-
-static int
-trace_profile_cleanup (trace_profile * profile)
-{
-
- memset (profile, 0, sizeof (trace_profile));
- profile->trace_tsp = TSP_MICROSECONDS; /* Micro seconds */
- ip6_trace_profile_cleanup (); /* lib-trace_TODO: Remove this once IOAM-IPv6 transport is a plugin */
- return 0;
-
-}
-
-static int
-trace_main_profiles_reset (void)
-{
- int rv;
-
- trace_main_t *sm = &trace_main;
- rv = trace_profile_cleanup (&(sm->profile));
- return (rv);
-}
-
-int
-trace_util_init (void)
-{
- int rv;
-
- rv = trace_main_profiles_reset ();
- return (rv);
-}
-
-
-int
-trace_profile_create (trace_profile * profile, u8 trace_type, u8 num_elts,
- u32 trace_tsp, u32 node_id, u32 app_data)
-{
-
- if (!trace_type || !num_elts || !(node_id))
- {
- return (-1);
- }
- if (profile && !profile->valid)
- {
- //rv = trace_profile_cleanup (profile);
- profile->trace_type = trace_type;
- profile->num_elts = num_elts;
- profile->trace_tsp = trace_tsp;
- profile->node_id = node_id;
- profile->app_data = app_data;
- profile->valid = 1;
-
- /* lib-trace_TODO: Remove this once IOAM-IPv6 transport is a plugin */
- ip6_trace_profile_setup ();
- return (0);
- }
-
- return (-1);
-}
-
-
-
-clib_error_t *
-clear_trace_profile_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
-
- trace_main_profiles_reset ();
- return 0;
-}
-
-void
-clear_trace_profiles (void)
-{
- clear_trace_profile_command_fn (0, 0, 0);
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND(clear_trace_profile_command) =
-{
-.path = "clear ioam-trace profile",
-.short_help = "clear ioam-trace profile [<index>|all]",
-.function = clear_trace_profile_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-set_trace_profile_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- u8 trace_type = 0;
- u8 num_elts = 0;
- u32 node_id = 0;
- u32 app_data = 0;
- u32 trace_tsp = 0;
- trace_profile *profile = NULL;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "trace-type 0x%x", &trace_type));
- else if (unformat (input, "trace-elts %d", &num_elts));
- else if (unformat (input, "trace-tsp %d", &trace_tsp));
- else if (unformat (input, "node-id 0x%x", &node_id));
- else if (unformat (input, "app-data 0x%x", &app_data));
- else
- break;
- }
- profile = trace_profile_find ();
- if (profile)
- {
- trace_profile_create (profile, trace_type, num_elts, trace_tsp,
- node_id, app_data);
- }
- return 0;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (set_trace_profile_command, static) =
-{
-.path = "set ioam-trace profile",
-.short_help = "set ioam-trace \
- trace-type <0x1f|0x3|0x9|0x11|0x19> trace-elts <nn> trace-tsp <0|1|2|3> \
- node-id <node id in hex> app-data <app_data in hex>",
-.function = set_trace_profile_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-show_trace_profile_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- trace_profile *p = NULL;
- u8 *s = 0;
- p = trace_profile_find ();
- if (!(p && p->valid))
- {
- s = format (s, "\nTrace configuration not valid\n");
- vlib_cli_output (vm, "%v", s);
- vec_free (s);
- return 0;
- }
- s = format (s, " HOP BY HOP OPTIONS - TRACE CONFIG - \n");
- s = format (s, " Trace Type : 0x%x (%d)\n",
- p->trace_type, p->trace_type);
- s =
- format (s, " Trace timestamp precision : %d (%s)\n",
- p->trace_tsp,
- (p->trace_tsp ==
- TSP_SECONDS) ? "Seconds" : ((p->trace_tsp ==
- TSP_MILLISECONDS) ?
- "Milliseconds"
- : (((p->trace_tsp ==
- TSP_MICROSECONDS) ?
- "Microseconds" :
- "Nanoseconds"))));
- s = format (s, " Num of trace nodes : %d\n", p->num_elts);
- s =
- format (s, " Node-id : 0x%x (%d)\n",
- p->node_id, p->node_id);
- s =
- format (s, " App Data : 0x%x (%d)\n",
- p->app_data, p->app_data);
- vlib_cli_output (vm, "%v", s);
- vec_free (s);
- return 0;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (show_trace_profile_command, static) =
-{
-.path = "show ioam-trace profile",
-.short_help = "show ioam-trace profile",
-.function = show_trace_profile_command_fn,
-};
-/* *INDENT-ON* */
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/plugins/ioam-plugin/ioam/lib-trace/trace_util.h b/plugins/ioam-plugin/ioam/lib-trace/trace_util.h
deleted file mode 100644
index 556f07ee3f1..00000000000
--- a/plugins/ioam-plugin/ioam/lib-trace/trace_util.h
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * trace_util.h -- Trace Profile Utility header
- *
- * 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.
- */
-
-#ifndef include_vnet_trace_util_h
-#define include_vnet_trace_util_h
-
-#define debug_ioam debug_ioam_fn
-
-
-/**
- * Usage:
- *
- * On any node that participates in iOAM Trace.
- *
- * Step 1: Initialize this library by calling trace_init()
- * Step 2: Setup a trace profile that contains all the parameters needed to compute cumulative:
- * Call these functions:
- * trace_profile_find
- * trace_profile_create
- * Step 2a: On initial node enable the profile to be used:
- * trace_profile_set_active / trace_profile_get_active will return the profile
- * Step 4: TBD
- * trace_validate
- *
- */
-
-typedef struct trace_profile_
-{
- u8 valid:1;
- u8 trace_type;
- u8 num_elts;
- /* Configured node-id */
- u32 node_id;
- u32 app_data;
- u32 trace_tsp;
-} trace_profile;
-
-typedef struct
-{
- /* Name of the default profile list in use */
- trace_profile profile;
-
- /* API message ID base */
- u16 msg_id_base;
-
- /* convenience */
- vlib_main_t *vlib_main;
- vnet_main_t *vnet_main;
-} trace_main_t;
-
-extern trace_main_t trace_main;
-
-/*
- * Initialize Trace profile
- */
-int trace_util_init (void);
-
-
-/*
- * Find a trace profile
- */
-
-always_inline trace_profile *
-trace_profile_find (void)
-{
- trace_main_t *sm = &trace_main;
-
- return (&(sm->profile));
-}
-
-
-/* setup and clean up profile */
-int trace_profile_create (trace_profile * profile, u8 trace_type, u8 num_elts,
- u32 trace_tsp, u32 node_id, u32 app_data);
-
-void clear_trace_profiles (void);
-
-
-
-#define BIT_TTL_NODEID (1<<0)
-#define BIT_ING_INTERFACE (1<<1)
-#define BIT_EGR_INTERFACE (1<<2)
-#define BIT_TIMESTAMP (1<<3)
-#define BIT_APPDATA (1<<4)
-#define TRACE_TYPE_MASK 0x1F /* Mask of all above bits */
-
-/*
- 0x00011111 iOAM-trace-type is 0x00011111 then the format of node
- data is:
-
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Hop_Lim | node_id |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ingress_if_id | egress_if_id |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- + timestamp +
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | app_data |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
-*/
-#define TRACE_TYPE_IF_TS_APP 0x1f
-typedef struct
-{
- u32 ttl_node_id;
- u16 ingress_if;
- u16 egress_if;
- u32 timestamp;
- u32 app_data;
-} ioam_trace_if_ts_app_t;
-
-/*
- 0x00000111 iOAM-trace-type is 0x00000111 then the format is:
-
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Hop_Lim | node_id |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ingress_if_id | egress_if_id |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
-*/
-
-#define TRACE_TYPE_IF 0x03
-typedef struct
-{
- u32 ttl_node_id;
- u16 ingress_if;
- u16 egress_if;
-} ioam_trace_if_t;
-
-/*
- 0x00001001 iOAM-trace-type is 0x00001001 then the format is:
-
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Hop_Lim | node_id |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- + timestamp +
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
-*/
-
-#define TRACE_TYPE_TS 0x09
-typedef struct
-{
- u32 ttl_node_id;
- u32 timestamp;
-} ioam_trace_ts_t;
-
-/*
- 0x00010001 iOAM-trace-type is 0x00010001 then the format is:
-
-
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Hop_Lim | node_id |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | app_data |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
-*/
-
-
-#define TRACE_TYPE_APP 0x11
-typedef struct
-{
- u32 ttl_node_id;
- u32 app_data;
-} ioam_trace_app_t;
-
-/*
-
- 0x00011001 iOAM-trace-type is 0x00011001 then the format is:
-
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Hop_Lim | node_id |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- + timestamp +
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | app_data |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-*/
-
-#define TRACE_TYPE_TS_APP 0x19
-typedef struct
-{
- u32 ttl_node_id;
- u32 timestamp;
- u32 app_data;
-} ioam_trace_ts_app_t;
-
-
-
-static inline u8
-fetch_trace_data_size (u8 trace_type)
-{
- u8 trace_data_size = 0;
-
- if (trace_type == TRACE_TYPE_IF_TS_APP)
- trace_data_size = sizeof (ioam_trace_if_ts_app_t);
- else if (trace_type == TRACE_TYPE_IF)
- trace_data_size = sizeof (ioam_trace_if_t);
- else if (trace_type == TRACE_TYPE_TS)
- trace_data_size = sizeof (ioam_trace_ts_t);
- else if (trace_type == TRACE_TYPE_APP)
- trace_data_size = sizeof (ioam_trace_app_t);
- else if (trace_type == TRACE_TYPE_TS_APP)
- trace_data_size = sizeof (ioam_trace_ts_app_t);
-
- return trace_data_size;
-}
-
-int ioam_trace_get_sizeof_handler (u32 * result);
-int ip6_trace_profile_setup (void);
-int ip6_trace_profile_cleanup (void);
-
-#define TSP_SECONDS 0
-#define TSP_MILLISECONDS 1
-#define TSP_MICROSECONDS 2
-#define TSP_NANOSECONDS 3
-
-#endif
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */