46 u8 data_list_elts_left;
48 }) vxlan_gpe_ioam_trace_option_t;
52 #define foreach_vxlan_gpe_ioam_trace_stats \ 53 _(SUCCESS, "Pkts updated with TRACE records") \ 54 _(FAILED, "Errors in TRACE due to lack of TRACE records") 56 static char *vxlan_gpe_ioam_trace_stats_strings[] = {
57 #define _(sym,string) string, 64 #define _(sym,str) VXLAN_GPE_IOAM_TRACE_##sym, 86 int rewrite_options (
u8 * rewrite_string,
124 u8 is_ipv4,
u8 use_adj),
154 hm->
trace[option] = NULL;
173 u32 *elt = va_arg (*args,
u32 *);
174 u8 *trace_type_p = va_arg (*args,
u8 *);
175 u8 trace_type = *trace_type_p;
180 u32 ttl_node_id_host_byte_order = clib_net_to_host_u32 (*elt);
181 s =
format (s,
"ttl 0x%x node id 0x%x ",
182 ttl_node_id_host_byte_order >> 24,
183 ttl_node_id_host_byte_order & 0x00FFFFFF);
190 u32 ingress_host_byte_order = clib_net_to_host_u32 (*elt);
191 s =
format (s,
"ingress 0x%x egress 0x%x ",
192 ingress_host_byte_order >> 16,
193 ingress_host_byte_order & 0xFFFF);
199 u32 ts_in_host_byte_order = clib_net_to_host_u32 (*elt);
200 s =
format (s,
"ts 0x%x \n", ts_in_host_byte_order);
206 u32 appdata_in_host_byte_order = clib_net_to_host_u32 (*elt);
207 s =
format (s,
"app 0x%x ", appdata_in_host_byte_order);
219 vxlan_gpe_ioam_trace_option_t *trace_option = NULL;
220 u8 trace_data_size = 0;
221 u8 trace_option_elts = 0;
235 trace_option_elts = profile->
num_elts;
237 trace_option = (vxlan_gpe_ioam_trace_option_t *) rewrite_string;
239 trace_option->hdr.length = 2 +
240 trace_option_elts * trace_data_size;
242 trace_option->data_list_elts_left = trace_option_elts;
244 sizeof (vxlan_gpe_ioam_trace_option_t) +
245 (trace_option_elts * trace_data_size);
254 u8 is_ipv4,
u8 use_adj)
257 vxlan_gpe_ioam_trace_option_t *
trace =
258 (vxlan_gpe_ioam_trace_option_t *) opt;
278 trace->data_list_elts_left--;
283 trace->data_list_elts_left *
285 elt = &trace->elts[elt_index];
295 *elt = clib_host_to_net_u32 (((ip0->
ttl - 1 + use_adj) << 24) |
308 tx_if = adj->rewrite_header.sw_if_index & 0xFFFF;
314 *elt = clib_host_to_net_u32 (*elt);
323 *elt = clib_host_to_net_u32 ((ip0->
hop_limit << 24) |
335 tx_if = adj->rewrite_header.sw_if_index & 0xFFFF;
341 *elt = clib_host_to_net_u32 (*elt);
354 *elt = clib_host_to_net_u32 (time_u64.
as_u32[0]);
361 *elt = clib_host_to_net_u32 (profile->
app_data);
365 (VXLAN_GPE_IOAM_TRACE_SUCCESS, 1);
370 (VXLAN_GPE_IOAM_TRACE_FAILED, 1);
379 vxlan_gpe_ioam_trace_option_t *
trace;
380 u8 trace_data_size_in_words = 0;
384 trace = (vxlan_gpe_ioam_trace_option_t *) opt;
386 format (s,
" Trace Type 0x%x , %d elts left\n", trace->ioam_trace_type,
387 trace->data_list_elts_left);
388 trace_data_size_in_words =
390 elt = &trace->elts[0];
391 while ((
u8 *) elt < ((
u8 *) (&trace->elts[0]) + trace->hdr.length - 2
394 s =
format (s,
" [%d] %U\n", elt_index,
396 elt, &trace->ioam_trace_type);
398 elt += trace_data_size_in_words;
415 s =
format (s,
" %s - %lu\n", vxlan_gpe_ioam_trace_stats_strings[i],
427 .path =
"show ioam vxlan-gpe trace",
428 .short_help =
"iOAM trace statistics",
448 (
"registration of VXLAN_GPE_OPTION_TYPE_IOAM_TRACE failed"));
453 sizeof (vxlan_gpe_ioam_trace_option_t),
456 (
"registration of VXLAN_GPE_OPTION_TYPE_IOAM_TRACE for rewrite failed"));
465 .runs_after =
VLIB_INITS(
"ip_main_init",
"ip6_lookup_init",
486 u8 trace_data_size = 0;
500 return VNET_API_ERROR_INVALID_VALUE;
503 return VNET_API_ERROR_INVALID_VALUE;
506 sizeof (vxlan_gpe_ioam_trace_option_t) +
507 profile->
num_elts * trace_data_size;
static void vxlan_gpe_ioam_trace_stats_increment_counter(u32 counter_index, u64 increment)
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
vnet_main_t * vnet_get_main(void)
vlib_main_t * vlib_main
State convenience vlib_main_t.
static int vxlan_gpe_ioam_trace_get_sizeof_handler(u32 *result)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static f64 vlib_time_now(vlib_main_t *vm)
static u8 fetch_trace_data_size(u16 trace_type)
static trace_profile * trace_profile_find(void)
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
static clib_error_t * vxlan_gpe_ioam_trace_init(vlib_main_t *vm)
#define VLIB_INIT_FUNCTION(x)
description fragment has unexpected format
vxlan_gpe_ioam_main_t vxlan_gpe_ioam_main
int vxlan_gpe_ioam_trace_rewrite_handler(u8 *rewrite_string, u8 *rewrite_size)
#define clib_error_create(args...)
int vxlan_gpe_trace_profile_setup(void)
int vxlan_gpe_ioam_register_option(u8 option, int options(vlib_buffer_t *b, vxlan_gpe_ioam_option_t *opt, u8 is_ipv4, u8 use_adj), u8 *trace(u8 *s, vxlan_gpe_ioam_option_t *opt))
int vxlan_gpe_ioam_add_register_option(u8 option, u8 size, int rewrite_options(u8 *rewrite_string, u8 *rewrite_size))
VXLAN GPE packet header structure.
u64 counters[ARRAY_LEN(vxlan_gpe_ioam_trace_stats_strings)]
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
typedef CLIB_PACKED(struct { vxlan_gpe_ioam_option_t hdr;u8 ioam_trace_type;u8 data_list_elts_left;u32 elts[0];})
static u32 counter_index(vlib_main_t *vm, vlib_error_t e)
#define VXLAN_GPE_OPTION_TYPE_IOAM_TRACE
#define foreach_vxlan_gpe_ioam_trace_stats
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
static clib_error_t * vxlan_gpe_show_ioam_trace_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vxlan_gpe_ioam_trace_main_t vxlan_gpe_ioam_trace_main
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
#define BIT_ING_INTERFACE
#define VLIB_CLI_COMMAND(x,...)
int(* add_options[256])(u8 *rewrite_string, u8 *rewrite_size)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
int vxlan_gpe_ioam_unregister_option(u8 option)
int vxlan_gpe_trace_profile_cleanup(void)
int(* options[256])(vlib_buffer_t *b, vxlan_gpe_ioam_option_t *opt, u8 is_ipv4, u8 use_adj)
vxlan_gpe_ioam_trace_stats_t
u8 * vxlan_gpe_ioam_trace_data_list_trace_handler(u8 *s, vxlan_gpe_ioam_option_t *opt)
VLIB buffer representation.
int vxlan_gpe_ioam_trace_data_list_handler(vlib_buffer_t *b, vxlan_gpe_ioam_option_t *opt, u8 is_ipv4, u8 use_adj)
static struct option options[]
static f64 trace_tsp_mul[4]
int vxlan_gpe_add_unregister_option(u8 option)
u8 *(* trace[256])(u8 *s, vxlan_gpe_ioam_option_t *opt)
static u8 * format_ioam_data_list_element(u8 *s, va_list *args)