aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/ioam-plugin/ioam
diff options
context:
space:
mode:
authorSagar Srivastav <sagsriva@cisco.com>2016-11-20 20:06:02 -0800
committerDamjan Marion <dmarion.lists@gmail.com>2016-12-09 20:12:18 +0000
commitd24625fbd1775a45ed0f262faf62cb6452aabb45 (patch)
treeb6c8da0c823f1d2406127d3b610bdb1b0ec24b30 /plugins/ioam-plugin/ioam
parent0ebe8d7d76964e07aec89ded7abe9216b90e2f59 (diff)
ioam:trace plugin - trace profile read API
Addition of read API to ioam-trace plugin which returns the current trace profile configured Change-Id: Ibe2baf0f60fb2a74ddc140747b53128aba975aaa Signed-off-by: Sagar Srivastav <sagsriva@cisco.com>
Diffstat (limited to 'plugins/ioam-plugin/ioam')
-rw-r--r--plugins/ioam-plugin/ioam/jvpp/io/fd/vpp/jvpp/ioamtrace/test/IoamTraceApiTest.java9
-rw-r--r--plugins/ioam-plugin/ioam/lib-trace/trace.api33
-rw-r--r--plugins/ioam-plugin/ioam/lib-trace/trace_api.c29
-rw-r--r--plugins/ioam-plugin/ioam/lib-trace/trace_test.c44
4 files changed, 110 insertions, 5 deletions
diff --git a/plugins/ioam-plugin/ioam/jvpp/io/fd/vpp/jvpp/ioamtrace/test/IoamTraceApiTest.java b/plugins/ioam-plugin/ioam/jvpp/io/fd/vpp/jvpp/ioamtrace/test/IoamTraceApiTest.java
index fa5c7ba4dc5..bc8c1c3a51c 100644
--- a/plugins/ioam-plugin/ioam/jvpp/io/fd/vpp/jvpp/ioamtrace/test/IoamTraceApiTest.java
+++ b/plugins/ioam-plugin/ioam/jvpp/io/fd/vpp/jvpp/ioamtrace/test/IoamTraceApiTest.java
@@ -20,10 +20,13 @@ import io.fd.vpp.jvpp.JVpp;
import io.fd.vpp.jvpp.JVppRegistry;
import io.fd.vpp.jvpp.JVppRegistryImpl;
import io.fd.vpp.jvpp.VppCallbackException;
+import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtraceFacade;
import io.fd.vpp.jvpp.ioamtrace.JVppIoamtraceImpl;
import io.fd.vpp.jvpp.ioamtrace.callback.TraceProfileAddCallback;
import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileAdd;
import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileAddReply;
+import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileShowConfig;
+import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileShowConfigReply;
public class IoamTraceApiTest {
@@ -50,7 +53,7 @@ public class IoamTraceApiTest {
System.out.println("Testing Java API for ioam trace plugin");
try (final JVppRegistry registry = new JVppRegistryImpl("ioamTraceApiTest");
final JVpp jvpp = new JVppIoamtraceImpl()) {
- registry.register(jvpp, new IoamTraceTestCallback());
+ FutureJVppIoamtraceFacade ioamtraceJvpp = new FutureJVppIoamtraceFacade(registry,jvpp);
System.out.println("Sending ioam trace profile add request...");
TraceProfileAdd request = new TraceProfileAdd();
@@ -64,6 +67,10 @@ public class IoamTraceApiTest {
Thread.sleep(1000);
+ TraceProfileShowConfig showRequest = new TraceProfileShowConfig();
+ TraceProfileShowConfigReply reply = ioamtraceJvpp.traceProfileShowConfig(showRequest).toCompletableFuture().get();
+ System.out.printf("TraceProfileShowConfig result = "+ reply.toString());
+
System.out.println("Disconnecting...");
}
}
diff --git a/plugins/ioam-plugin/ioam/lib-trace/trace.api b/plugins/ioam-plugin/ioam/lib-trace/trace.api
index 016dd24c976..cb9583256f6 100644
--- a/plugins/ioam-plugin/ioam/lib-trace/trace.api
+++ b/plugins/ioam-plugin/ioam/lib-trace/trace.api
@@ -16,7 +16,6 @@
/** \brief iOAM6 Trace - Set the iOAM6 trace profile
- @param id - id of the profile
@param trace_type - Type of trace requested
@param num_elts - Number of trace elements to be inserted
@param node_id - Trace Node ID
@@ -47,8 +46,6 @@ define trace_profile_add_reply {
/** \brief Delete trace Profile
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
- @param list_name_len - length of the name of the profile list
- @param list_name - name of profile list to delete
*/
define trace_profile_del {
u32 client_index;
@@ -63,3 +60,33 @@ 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_api.c b/plugins/ioam-plugin/ioam/lib-trace/trace_api.c
index e35bb7c4243..7e0d708e155 100644
--- a/plugins/ioam-plugin/ioam/lib-trace/trace_api.c
+++ b/plugins/ioam-plugin/ioam/lib-trace/trace_api.c
@@ -84,7 +84,7 @@ do { \
return; \
\
rmp = vl_msg_api_alloc (sizeof (*rmp)); \
- rmp->_vl_msg_id = ntohs((t)); \
+ rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \
rmp->context = mp->context; \
rmp->retval = ntohl(rv); \
do {body;} while (0); \
@@ -97,6 +97,7 @@ do { \
#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)
@@ -137,6 +138,32 @@ static void vl_api_trace_profile_del_t_handler
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
diff --git a/plugins/ioam-plugin/ioam/lib-trace/trace_test.c b/plugins/ioam-plugin/ioam/lib-trace/trace_test.c
index 8385582f438..7a03fa21059 100644
--- a/plugins/ioam-plugin/ioam/lib-trace/trace_test.c
+++ b/plugins/ioam-plugin/ioam/lib-trace/trace_test.c
@@ -23,6 +23,7 @@
#include <vlibmemory/api.h>
#include <vlibsocket/api.h>
#include <vppinfra/error.h>
+#include <vnet/ip/ip6_hop_by_hop.h>
/* Declare message IDs */
#include <ioam/lib-trace/trace_msg_enum.h>
@@ -63,6 +64,18 @@ trace_test_main_t trace_test_main;
_(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 (%s)\n",mp->trace_tsp, \
+ (mp->trace_tsp == TSP_SECONDS) ? "Seconds" : ((mp->trace_tsp ==TSP_MILLISECONDS) ? \
+ "Milliseconds": (((mp->trace_tsp == TSP_MICROSECONDS) ? "Microseconds" : "Nanoseconds")))); \
+ 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) \
@@ -79,6 +92,23 @@ _(trace_profile_del_reply)
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
@@ -86,6 +116,7 @@ foreach_standard_reply_retval_handler;
#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 */
@@ -186,6 +217,18 @@ api_trace_profile_del (vat_main_t * vam)
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
@@ -194,6 +237,7 @@ api_trace_profile_del (vat_main_t * vam)
_(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