From 03f2a015999ed9ba34041afb408a22ea5fe601ff Mon Sep 17 00:00:00 2001 From: Benoît Ganne Date: Tue, 20 Jul 2021 16:49:13 +0200 Subject: vlib: add format_vnet_buffer_no_chain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - add format_vnet_buffer and format_vnet_buffer_no_chain to mirror format_vlib_buffer and format_vlib_buffer_no_chain - format_vnet_buffer used to be the "no chain" version, replace all of its current use with the corresponding format_vnet_buffer_no_chain - add a function to dump vnet buffer details from gdb Type: improvement Change-Id: I143ce845f80e7ef937ea33a557b6e3b5988c5b8f Signed-off-by: Benoît Ganne --- extras/deprecated/ixge/ixge.c | 10 ++++------ src/plugins/dpdk/device/format.c | 10 ++++------ src/plugins/vmxnet3/format.c | 2 +- src/vnet/buffer.c | 21 +++++++++++++++++---- src/vnet/buffer.h | 2 +- src/vnet/devices/virtio/device.c | 5 ++--- src/vnet/pg/input.c | 6 +++--- src/vnet/pg/stream.c | 5 ++--- src/vnet/unix/gdb_funcs.c | 6 ++++++ 9 files changed, 40 insertions(+), 27 deletions(-) diff --git a/extras/deprecated/ixge/ixge.c b/extras/deprecated/ixge/ixge.c index bb91a368488..481db06594e 100644 --- a/extras/deprecated/ixge/ixge.c +++ b/extras/deprecated/ixge/ixge.c @@ -599,9 +599,8 @@ format_ixge_rx_dma_trace (u8 * s, va_list * va) format_white_space, indent, t->after.rx_to_hw.head_address, t->after.rx_to_hw.tail_address); - s = format (s, "\n%Ubuffer 0x%x: %U", - format_white_space, indent, - t->buffer_index, format_vnet_buffer, &t->buffer); + s = format (s, "\n%Ubuffer 0x%x: %U", format_white_space, indent, + t->buffer_index, format_vnet_buffer_no_chain, &t->buffer); s = format (s, "\n%U", format_white_space, indent); @@ -883,9 +882,8 @@ format_ixge_tx_dma_trace (u8 * s, va_list * va) format_white_space, indent, format_ixge_tx_descriptor, &t->descriptor); - s = format (s, "\n%Ubuffer 0x%x: %U", - format_white_space, indent, - t->buffer_index, format_vnet_buffer, &t->buffer); + s = format (s, "\n%Ubuffer 0x%x: %U", format_white_space, indent, + t->buffer_index, format_vnet_buffer_no_chain, &t->buffer); s = format (s, "\n%U", format_white_space, indent); diff --git a/src/plugins/dpdk/device/format.c b/src/plugins/dpdk/device/format.c index 24994aa9426..71f0d89454b 100644 --- a/src/plugins/dpdk/device/format.c +++ b/src/plugins/dpdk/device/format.c @@ -761,9 +761,8 @@ format_dpdk_tx_trace (u8 * s, va_list * va) s = format (s, "%U tx queue %d", format_vnet_sw_interface_name, vnm, sw, t->queue_index); - s = format (s, "\n%Ubuffer 0x%x: %U", - format_white_space, indent, - t->buffer_index, format_vnet_buffer, &t->buffer); + s = format (s, "\n%Ubuffer 0x%x: %U", format_white_space, indent, + t->buffer_index, format_vnet_buffer_no_chain, &t->buffer); s = format (s, "\n%U%U", format_white_space, indent, @@ -792,9 +791,8 @@ format_dpdk_rx_trace (u8 * s, va_list * va) s = format (s, "%U rx queue %d", format_vnet_sw_interface_name, vnm, sw, t->queue_index); - s = format (s, "\n%Ubuffer 0x%x: %U", - format_white_space, indent, - t->buffer_index, format_vnet_buffer, &t->buffer); + s = format (s, "\n%Ubuffer 0x%x: %U", format_white_space, indent, + t->buffer_index, format_vnet_buffer_no_chain, &t->buffer); s = format (s, "\n%U%U", format_white_space, indent, diff --git a/src/plugins/vmxnet3/format.c b/src/plugins/vmxnet3/format.c index d463feb3bec..43d790d31eb 100644 --- a/src/plugins/vmxnet3/format.c +++ b/src/plugins/vmxnet3/format.c @@ -164,7 +164,7 @@ format_vmxnet3_input_trace (u8 * s, va_list * args) s = format (s, "vmxnet3: %v (%d) next-node %U", hi->name, t->hw_if_index, format_vlib_next_node_name, vm, node->index, t->next_index); - s = format (s, "\n buffer %U", format_vnet_buffer, &t->buffer); + s = format (s, "\n buffer %U", format_vnet_buffer_no_chain, &t->buffer); return s; } diff --git a/src/vnet/buffer.c b/src/vnet/buffer.c index ef93185b2c1..721f856ddda 100644 --- a/src/vnet/buffer.c +++ b/src/vnet/buffer.c @@ -37,10 +37,9 @@ format_vnet_buffer_offload (u8 *s, va_list *args) return s; } -u8 * -format_vnet_buffer (u8 * s, va_list * args) +static u8 * +format_vnet_buffer_internal (u8 *s, vlib_buffer_t *b, int no_chain) { - vlib_buffer_t *b = va_arg (*args, vlib_buffer_t *); u32 indent = format_get_indent (s); u8 *a = 0; @@ -72,7 +71,8 @@ format_vnet_buffer (u8 * s, va_list * args) if (b->flags & VNET_BUFFER_F_LOOP_COUNTER_VALID) a = format (a, "loop-counter %d ", vnet_buffer2 (b)->loop_counter); - s = format (s, "%U", format_vlib_buffer_no_chain, b); + s = format (s, "%U", + no_chain ? format_vlib_buffer_no_chain : format_vlib_buffer, b); if (a) s = format (s, "\n%U%v", format_white_space, indent, a); vec_free (a); @@ -80,6 +80,19 @@ format_vnet_buffer (u8 * s, va_list * args) return s; } +u8 * +format_vnet_buffer_no_chain (u8 *s, va_list *args) +{ + vlib_buffer_t *b = va_arg (*args, vlib_buffer_t *); + return format_vnet_buffer_internal (s, b, 1 /* no_chain */); +} + +u8 * +format_vnet_buffer (u8 *s, va_list *args) +{ + vlib_buffer_t *b = va_arg (*args, vlib_buffer_t *); + return format_vnet_buffer_internal (s, b, 0 /* no_chain */); +} /* * fd.io coding-style-patch-verification: ON diff --git a/src/vnet/buffer.h b/src/vnet/buffer.h index 600782c3864..cbaf4d84e42 100644 --- a/src/vnet/buffer.h +++ b/src/vnet/buffer.h @@ -517,7 +517,7 @@ STATIC_ASSERT (sizeof (vnet_buffer_opaque2_t) <= vnet_buffer(b)->l4_hdr_offset - \ vnet_buffer (b)->l3_hdr_offset) - +format_function_t format_vnet_buffer_no_chain; format_function_t format_vnet_buffer; format_function_t format_vnet_buffer_offload; format_function_t format_vnet_buffer_flags; diff --git a/src/vnet/devices/virtio/device.c b/src/vnet/devices/virtio/device.c index aa816e2e17d..6c2fe34abf0 100644 --- a/src/vnet/devices/virtio/device.c +++ b/src/vnet/devices/virtio/device.c @@ -88,9 +88,8 @@ format_virtio_tx_trace (u8 * s, va_list * va) virtio_tx_trace_t *t = va_arg (*va, virtio_tx_trace_t *); u32 indent = format_get_indent (s); - s = format (s, "%Ubuffer 0x%x: %U\n", - format_white_space, indent, - t->buffer_index, format_vnet_buffer, &t->buffer); + s = format (s, "%Ubuffer 0x%x: %U\n", format_white_space, indent, + t->buffer_index, format_vnet_buffer_no_chain, &t->buffer); s = format (s, "%U%U\n", format_white_space, indent, format_generic_header_offset, &t->gho); diff --git a/src/vnet/pg/input.c b/src/vnet/pg/input.c index 98db46abd6a..17b7c518385 100644 --- a/src/vnet/pg/input.c +++ b/src/vnet/pg/input.c @@ -78,7 +78,7 @@ validate_buffer_data2 (vlib_buffer_t * b, pg_stream_t * s, if (i >= n_bytes) return 1; - clib_warning ("buffer %U", format_vnet_buffer, b); + clib_warning ("buffer %U", format_vnet_buffer_no_chain, b); clib_warning ("differ at index %d", i); clib_warning ("is %U", format_hex_bytes, bd, n_bytes); clib_warning ("mask %U", format_hex_bytes, pm, n_bytes); @@ -1435,8 +1435,8 @@ format_pg_input_trace (u8 * s, va_list * va) s = format (s, ", %d bytes", t->packet_length); s = format (s, ", sw_if_index %d", t->sw_if_index); - s = format (s, "\n%U%U", - format_white_space, indent, format_vnet_buffer, &t->buffer); + s = format (s, "\n%U%U", format_white_space, indent, + format_vnet_buffer_no_chain, &t->buffer); s = format (s, "\n%U", format_white_space, indent); diff --git a/src/vnet/pg/stream.c b/src/vnet/pg/stream.c index 686627b8d9a..605567c1296 100644 --- a/src/vnet/pg/stream.c +++ b/src/vnet/pg/stream.c @@ -102,9 +102,8 @@ format_pg_output_trace (u8 * s, va_list * va) pg_output_trace_t *t = va_arg (*va, pg_output_trace_t *); u32 indent = format_get_indent (s); - s = format (s, "%Ubuffer 0x%x: %U", - format_white_space, indent, - t->buffer_index, format_vnet_buffer, &t->buffer); + s = format (s, "%Ubuffer 0x%x: %U", format_white_space, indent, + t->buffer_index, format_vnet_buffer_no_chain, &t->buffer); s = format (s, "\n%U%U", format_white_space, indent, format_ethernet_header_with_length, t->buffer.pre_data, diff --git a/src/vnet/unix/gdb_funcs.c b/src/vnet/unix/gdb_funcs.c index 886d849c173..91dabe394ba 100644 --- a/src/vnet/unix/gdb_funcs.c +++ b/src/vnet/unix/gdb_funcs.c @@ -421,6 +421,12 @@ gdb_dump_trajectory_trace (u32 bi) #endif } +void +gdb_dump_buffer (vlib_buffer_t *b) +{ + fformat (stderr, "%U\n", format_vnet_buffer, b); +} + /* Cafeteria plan, maybe you don't want these functions */ clib_error_t * gdb_func_init (vlib_main_t * vm) -- cgit 1.2.3-korg