diff options
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/devices/virtio/device.c | 70 |
1 files changed, 37 insertions, 33 deletions
diff --git a/src/vnet/devices/virtio/device.c b/src/vnet/devices/virtio/device.c index 1f1abfded77..6f7d1f664dc 100644 --- a/src/vnet/devices/virtio/device.c +++ b/src/vnet/devices/virtio/device.c @@ -100,6 +100,42 @@ format_virtio_tx_trace (u8 * s, va_list * va) } static_always_inline void +virtio_tx_trace (vlib_main_t * vm, vlib_node_runtime_t * node, + virtio_if_type_t type, vlib_buffer_t * b0, u32 bi) +{ + virtio_tx_trace_t *t; + t = vlib_add_trace (vm, node, b0, sizeof (t[0])); + t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; + t->buffer_index = bi; + if (type == VIRTIO_IF_TYPE_TUN) + { + int is_ip4 = 0, is_ip6 = 0; + + switch (((u8 *) vlib_buffer_get_current (b0))[0] & 0xf0) + { + case 0x40: + is_ip4 = 1; + break; + case 0x60: + is_ip6 = 1; + break; + default: + break; + } + vnet_generic_header_offset_parser (b0, &t->gho, 0, is_ip4, is_ip6); + } + else + vnet_generic_header_offset_parser (b0, &t->gho, 1, + b0->flags & + VNET_BUFFER_F_IS_IP4, + b0->flags & VNET_BUFFER_F_IS_IP6); + + clib_memcpy_fast (&t->buffer, b0, sizeof (*b0) - sizeof (b0->pre_data)); + clib_memcpy_fast (t->buffer.pre_data, vlib_buffer_get_current (b0), + sizeof (t->buffer.pre_data)); +} + +static_always_inline void virtio_interface_drop_inline (vlib_main_t * vm, uword node_index, u32 * buffers, u16 n, virtio_tx_func_error_t error) @@ -555,43 +591,11 @@ retry: while (n_left && free_desc_count) { u16 n_added = 0; - virtio_tx_trace_t *t; vlib_buffer_t *b0 = vlib_get_buffer (vm, buffers[0]); if (b0->flags & VLIB_BUFFER_IS_TRACED) { - t = vlib_add_trace (vm, node, b0, sizeof (t[0])); - t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; - t->buffer_index = buffers[0]; - if (type == VIRTIO_IF_TYPE_TUN) - { - int is_ip4 = 0, is_ip6 = 0; - - switch (((u8 *) vlib_buffer_get_current (b0))[0] & 0xf0) - { - case 0x40: - is_ip4 = 1; - break; - case 0x60: - is_ip6 = 1; - break; - default: - break; - } - vnet_generic_header_offset_parser (b0, &t->gho, 0, is_ip4, - is_ip6); - } - else - vnet_generic_header_offset_parser (b0, &t->gho, 1, - b0->flags & - VNET_BUFFER_F_IS_IP4, - b0->flags & - VNET_BUFFER_F_IS_IP6); - - clib_memcpy_fast (&t->buffer, b0, - sizeof (*b0) - sizeof (b0->pre_data)); - clib_memcpy_fast (t->buffer.pre_data, vlib_buffer_get_current (b0), - sizeof (t->buffer.pre_data)); + virtio_tx_trace (vm, node, type, b0, buffers[0]); } n_added = add_buffer_to_slot (vm, vif, type, vring, buffers[0], free_desc_count, |