diff options
author | Damjan Marion <damarion@cisco.com> | 2016-06-09 16:16:27 +0200 |
---|---|---|
committer | Chris Luke <chris_luke@cable.comcast.com> | 2016-06-09 20:03:34 +0000 |
commit | db7b2697360dbcc6198ec0518db817050876fef2 (patch) | |
tree | c71920d41b1992028b890f8d9505958fa8631f8c | |
parent | a7e83ceeacccb20516ffdd8e1beb9695c1e977b1 (diff) |
Add verbose flag for packet trace, show hexdump in verbose dpdk input trace
Verbose trace can be enabled with:
trace add dpdk-input 1 verbose
Change-Id: If58cfc561143d5a44f7d11e61d54b6835692a0e3
Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r-- | vlib/vlib/trace.c | 17 | ||||
-rw-r--r-- | vlib/vlib/trace.h | 3 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/dpdk.h | 1 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/format.c | 12 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/node.c | 1 |
5 files changed, 27 insertions, 7 deletions
diff --git a/vlib/vlib/trace.c b/vlib/vlib/trace.c index d430460be32..86a04aa64d1 100644 --- a/vlib/vlib/trace.c +++ b/vlib/vlib/trace.c @@ -359,12 +359,18 @@ cli_add_trace_buffer (vlib_main_t * vm, vlib_trace_main_t * tm; vlib_trace_node_t * tn; u32 node_index, add; + u8 verbose = 0; - if (unformat (input, "%U %d", unformat_vlib_node, vm, &node_index, &add)) - ; - else - return clib_error_create ("expected NODE COUNT, got `%U'", - format_unformat_error, input); + while (unformat_check_input(input) != (uword)UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "%U %d", unformat_vlib_node, vm, &node_index, &add)) + ; + else if (unformat (input, "verbose")) + verbose = 1; + else + return clib_error_create ("expected NODE COUNT, got `%U'", + format_unformat_error, input); + } foreach_vlib_main ( ({ @@ -372,6 +378,7 @@ cli_add_trace_buffer (vlib_main_t * vm, tm = &this_vlib_main->trace_main; tm->trace_active_hint = 1; + tm->verbose = verbose; oldheap = clib_mem_set_heap (this_vlib_main->heap_base); diff --git a/vlib/vlib/trace.h b/vlib/vlib/trace.h index fe5d7377861..6e9ed495734 100644 --- a/vlib/vlib/trace.h +++ b/vlib/vlib/trace.h @@ -81,6 +81,9 @@ typedef struct { /* Per node trace counts. */ vlib_trace_node_t * nodes; + + /* verbosity */ + int verbose; } vlib_trace_main_t; #endif /* included_vlib_trace_h */ diff --git a/vnet/vnet/devices/dpdk/dpdk.h b/vnet/vnet/devices/dpdk/dpdk.h index 23c8eb3eaf5..9032b7a9152 100644 --- a/vnet/vnet/devices/dpdk/dpdk.h +++ b/vnet/vnet/devices/dpdk/dpdk.h @@ -467,6 +467,7 @@ typedef struct { u16 queue_index; struct rte_mbuf mb; vlib_buffer_t buffer; /* Copy of VLIB buffer; pkt data stored in pre_data. */ + u8 data[256]; /* First 256 data bytes, used for hexdump */ } dpdk_rx_dma_trace_t; void vnet_buffer_needs_dpdk_mb (vlib_buffer_t * b); diff --git a/vnet/vnet/devices/dpdk/format.c b/vnet/vnet/devices/dpdk/format.c index 3aee0d9275f..6e777460f95 100644 --- a/vnet/vnet/devices/dpdk/format.c +++ b/vnet/vnet/devices/dpdk/format.c @@ -662,6 +662,14 @@ u8 * format_dpdk_rx_dma_trace (u8 * s, va_list * va) format_white_space, indent, format_dpdk_rte_mbuf, &t->mb); #endif /* RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS */ + if (vm->trace_main.verbose) + { + s = format (s, "\n%UPacket Dump%s", format_white_space, indent + 2, + t->mb.data_len > sizeof(t->data) ? " (truncated)": ""); + s = format (s, "\n%U%U", format_white_space, indent + 4, + format_hexdump, &t->data, + t->mb.data_len > sizeof(t->data) ? sizeof(t->data) : t->mb.data_len); + } f = node->format_buffer; if (!f) f = format_hex_bytes; @@ -726,11 +734,11 @@ u8 * format_dpdk_rte_mbuf (u8 * s, va_list * va) uword indent = format_get_indent (s) + 2; s = format (s, "PKT MBUF: port %d, nb_segs %d, pkt_len %d" - "\n%Ubuf_len %d, data_len %d, ol_flags 0x%x," + "\n%Ubuf_len %d, data_len %d, ol_flags 0x%x, data_off %d" "\n%Upacket_type 0x%x", mb->port, mb->nb_segs, mb->pkt_len, format_white_space, indent, - mb->buf_len, mb->data_len, mb->ol_flags, + mb->buf_len, mb->data_len, mb->ol_flags, mb->data_off, format_white_space, indent, mb->packet_type); diff --git a/vnet/vnet/devices/dpdk/node.c b/vnet/vnet/devices/dpdk/node.c index d22838f1f06..9a0f9c8fb49 100644 --- a/vnet/vnet/devices/dpdk/node.c +++ b/vnet/vnet/devices/dpdk/node.c @@ -380,6 +380,7 @@ void dpdk_rx_trace (dpdk_main_t * dm, clib_memcpy (&t0->mb, mb, sizeof (t0->mb)); clib_memcpy (&t0->buffer, b0, sizeof (b0[0]) - sizeof (b0->pre_data)); clib_memcpy (t0->buffer.pre_data, b0->data, sizeof (t0->buffer.pre_data)); + clib_memcpy (&t0->data, mb->buf_addr + mb->data_off, sizeof (t0->data)); #ifdef RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS /* |