summaryrefslogtreecommitdiffstats
path: root/plugins/ioam-plugin/ioam/lib-trace
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/ioam-plugin/ioam/lib-trace')
-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
3 files changed, 102 insertions, 4 deletions
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