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),
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) |
309 tx_if = adj->rewrite_header.sw_if_index & 0xFFFF;
315 *elt = clib_host_to_net_u32 (*elt);
324 *elt = clib_host_to_net_u32 ((ip0->
hop_limit << 24) |
337 tx_if = adj->rewrite_header.sw_if_index & 0xFFFF;
343 *elt = clib_host_to_net_u32 (*elt);
356 *elt = clib_host_to_net_u32 (time_u64.
as_u32[0]);
363 *elt = clib_host_to_net_u32 (profile->
app_data);
367 (VXLAN_GPE_IOAM_TRACE_SUCCESS, 1);
372 (VXLAN_GPE_IOAM_TRACE_FAILED, 1);
381 vxlan_gpe_ioam_trace_option_t *
trace;
382 u8 trace_data_size_in_words = 0;
386 trace = (vxlan_gpe_ioam_trace_option_t *) opt;
388 format (s,
" Trace Type 0x%x , %d elts left\n", trace->ioam_trace_type,
389 trace->data_list_elts_left);
390 trace_data_size_in_words =
392 elt = &trace->elts[0];
393 while ((
u8 *) elt < ((
u8 *) (&trace->elts[0]) + trace->hdr.length - 2
396 s =
format (s,
" [%d] %U\n", elt_index,
398 elt, &trace->ioam_trace_type);
400 elt += trace_data_size_in_words;
417 s =
format (s,
" %s - %lu\n", vxlan_gpe_ioam_trace_stats_strings[i],
429 .path =
"show ioam vxlan-gpe trace",
430 .short_help =
"iOAM trace statistics",
460 (
"registration of VXLAN_GPE_OPTION_TYPE_IOAM_TRACE failed"));
465 sizeof (vxlan_gpe_ioam_trace_option_t),
468 (
"registration of VXLAN_GPE_OPTION_TYPE_IOAM_TRACE for rewrite failed"));
491 u8 trace_data_size = 0;
505 return VNET_API_ERROR_INVALID_VALUE;
508 return VNET_API_ERROR_INVALID_VALUE;
511 sizeof (vxlan_gpe_ioam_trace_option_t) +
512 profile->
num_elts * trace_data_size;
static void vxlan_gpe_ioam_trace_stats_increment_counter(u32 counter_index, u64 increment)
sll srl srl sll sra u16x4 i
clib_error_t * vxlan_gpe_init(vlib_main_t *vm)
Feature init function for VXLAN GPE.
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
vlib_main_t * vlib_main
State convenience vlib_main_t.
static int vxlan_gpe_ioam_trace_get_sizeof_handler(u32 *result)
static f64 vlib_time_now(vlib_main_t *vm)
ip_lookup_main_t lookup_main
typedef CLIB_PACKED(struct{vxlan_gpe_ioam_option_t hdr;u8 ioam_trace_type;u8 data_list_elts_left;u32 elts[0];})
vnet_main_t * vnet_get_main(void)
static clib_error_t * vxlan_gpe_ioam_trace_init(vlib_main_t *vm)
#define VLIB_INIT_FUNCTION(x)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static u32 counter_index(vlib_main_t *vm, vlib_error_t e)
vxlan_gpe_ioam_main_t vxlan_gpe_ioam_main
int vxlan_gpe_ioam_trace_rewrite_handler(u8 *rewrite_string, u8 *rewrite_size)
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))
#define vlib_call_init_function(vm, x)
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)]
#define clib_error_create(args...)
static u8 fetch_trace_data_size(u8 trace_type)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
#define VXLAN_GPE_OPTION_TYPE_IOAM_TRACE
#define foreach_vxlan_gpe_ioam_trace_stats
clib_error_t * ip_main_init(vlib_main_t *vm)
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
#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)
ip_lookup_main_t lookup_main
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)
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 f64 trace_tsp_mul[4]
ip4_main_t ip4_main
Global ip4 main structure.
int vxlan_gpe_add_unregister_option(u8 option)
static trace_profile * trace_profile_find(void)
static clib_error_t * ip6_lookup_init(vlib_main_t *vm)
static ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
u8 *(* trace[256])(u8 *s, vxlan_gpe_ioam_option_t *opt)
static u8 * format_ioam_data_list_element(u8 *s, va_list *args)