46 u8 data_list_elts_left;
48 }) ioam_trace_option_t;
55 #define foreach_ip6_hop_by_hop_ioam_trace_stats \ 56 _(PROCESSED, "Pkts with ip6 hop-by-hop trace options") \ 57 _(PROFILE_MISS, "Pkts with ip6 hop-by-hop trace options but no profile set") \ 58 _(UPDATED, "Pkts with trace updated") \ 59 _(FULL, "Pkts with trace options but no space") 61 static char *ip6_hop_by_hop_ioam_trace_stats_strings[] = {
62 #define _(sym,string) string, 69 #define _(sym,str) IP6_IOAM_TRACE_##sym, 100 u32 *elt = va_arg (*args,
u32 *);
101 u8 *trace_type_p = va_arg (*args,
u8 *);
102 u8 trace_type = *trace_type_p;
107 u32 ttl_node_id_host_byte_order = clib_net_to_host_u32 (*elt);
108 s =
format (s,
"ttl 0x%x node id 0x%x ",
109 ttl_node_id_host_byte_order >> 24,
110 ttl_node_id_host_byte_order & 0x00FFFFFF);
117 u32 ingress_host_byte_order = clib_net_to_host_u32 (*elt);
118 s =
format (s,
"ingress 0x%x egress 0x%x ",
119 ingress_host_byte_order >> 16,
120 ingress_host_byte_order & 0xFFFF);
126 u32 ts_in_host_byte_order = clib_net_to_host_u32 (*elt);
127 s =
format (s,
"ts 0x%x \n", ts_in_host_byte_order);
133 u32 appdata_in_host_byte_order = clib_net_to_host_u32 (*elt);
134 s =
format (s,
"app 0x%x ", appdata_in_host_byte_order);
146 u8 trace_data_size = 0;
161 return VNET_API_ERROR_INVALID_VALUE;
164 return VNET_API_ERROR_INVALID_VALUE;
167 sizeof (ioam_trace_option_t) + (profile->
num_elts * trace_data_size);
179 ioam_trace_option_t *trace_option =
NULL;
180 u8 trace_data_size = 0;
181 u8 trace_option_elts = 0;
196 trace_option_elts = profile->
num_elts;
198 trace_option = (ioam_trace_option_t *) rewrite_string;
201 trace_option->hdr.length = 2 +
202 trace_option_elts * trace_data_size;
204 trace_option->data_list_elts_left = trace_option_elts;
206 sizeof (ioam_trace_option_t) + (trace_option_elts * trace_data_size);
220 ioam_trace_option_t *
trace = (ioam_trace_option_t *) opt;
242 trace->data_list_elts_left--;
247 trace->data_list_elts_left *
249 elt = &trace->elts[elt_index];
261 (adj->rewrite_header.sw_if_index & 0xFFFF);
262 *elt = clib_host_to_net_u32 (*elt);
274 *elt = clib_host_to_net_u32 (time_u64.
as_u32[0]);
281 *elt = clib_host_to_net_u32 (profile->
app_data);
297 ioam_trace_option_t *
trace;
298 u8 trace_data_size_in_words = 0;
302 trace = (ioam_trace_option_t *) opt;
304 format (s,
" Trace Type 0x%x , %d elts left\n", trace->ioam_trace_type,
305 trace->data_list_elts_left);
306 trace_data_size_in_words =
308 elt = &trace->elts[0];
309 while ((
u8 *) elt < ((
u8 *) (&trace->elts[0]) + trace->hdr.length - 2
312 s =
format (s,
" [%d] %U\n", elt_index,
314 elt, &trace->ioam_trace_type);
316 elt += trace_data_size_in_words;
334 format (s,
" %s - %lu\n", ip6_hop_by_hop_ioam_trace_stats_strings[i],
346 .path =
"show ioam trace",
347 .short_help =
"iOAM trace statistics",
390 (
"registration of HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST failed"));
394 sizeof (ioam_trace_option_t),
398 (
"registration of HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST for rewrite failed"));
ip6_hop_by_hop_ioam_main_t ip6_hop_by_hop_ioam_main
sll srl srl sll sra u16x4 i
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
#define foreach_ip6_hop_by_hop_ioam_trace_stats
static f64 vlib_time_now(vlib_main_t *vm)
int ip6_hbh_register_option(u8 option, int options(vlib_buffer_t *b, ip6_header_t *ip, ip6_hop_by_hop_option_t *opt), u8 *trace(u8 *s, ip6_hop_by_hop_option_t *opt))
typedef CLIB_PACKED(struct{ip6_hop_by_hop_option_t hdr;u8 ioam_trace_type;u8 data_list_elts_left;u32 elts[0];})
vnet_main_t * vnet_get_main(void)
#define VLIB_INIT_FUNCTION(x)
int ip6_trace_profile_setup(void)
int ip6_hop_by_hop_ioam_trace_rewrite_handler(u8 *rewrite_string, u8 *rewrite_size)
ip6_hop_by_hop_ioam_trace_main_t ip6_hop_by_hop_ioam_trace_main
static u32 counter_index(vlib_main_t *vm, vlib_error_t e)
#define vlib_call_init_function(vm, x)
u8 options_size[MAX_IP6_HBH_OPTION]
#define clib_error_create(args...)
static u8 fetch_trace_data_size(u8 trace_type)
static u8 * format_ioam_data_list_element(u8 *s, va_list *args)
int ip6_hbh_ioam_trace_data_list_handler(vlib_buffer_t *b, ip6_header_t *ip, ip6_hop_by_hop_option_t *opt)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
int ip6_trace_profile_cleanup(void)
clib_error_t * ip_main_init(vlib_main_t *vm)
#define vec_free(V)
Free vector's memory (no header).
static void ip6_ioam_trace_stats_increment_counter(u32 counter_index, u64 increment)
static clib_error_t * ip6_show_ioam_trace_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_error_t * vlib_plugin_register(vlib_main_t *vm, vnet_plugin_handoff_t *h, int from_early_init)
#define BIT_ING_INTERFACE
#define VLIB_CLI_COMMAND(x,...)
ip_lookup_main_t lookup_main
#define HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST
static clib_error_t * ip6_hop_by_hop_ioam_init(vlib_main_t *vm)
#define HBH_OPTION_TYPE_DATA_CHANGE_ENROUTE
static clib_error_t * ip6_hop_by_hop_ioam_trace_init(vlib_main_t *vm)
static trace_profile * trace_profile_find(void)
int ip6_hbh_add_register_option(u8 option, u8 size, int rewrite_options(u8 *rewrite_string, u8 *rewrite_size))
int ip6_ioam_trace_get_sizeof_handler(u32 *result)
static clib_error_t * ip6_lookup_init(vlib_main_t *vm)
static f64 trace_tsp_mul[4]
u8 * ip6_hbh_ioam_trace_data_list_trace_handler(u8 *s, ip6_hop_by_hop_option_t *opt)
static ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
u64 counters[ARRAY_LEN(ip6_hop_by_hop_ioam_trace_stats_strings)]