summaryrefslogtreecommitdiffstats
path: root/src/vnet/interface_output.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-02-25 15:27:28 -0500
committerDamjan Marion <dmarion@me.com>2019-02-26 11:30:29 +0000
commit5ecd5a5d159332a964dd840fcdabe5f8d3111b0e (patch)
tree99c6fbcd96efce44215bb06363126acfa88f8fb0 /src/vnet/interface_output.c
parentf6defa113e2e10a70c5a92ce7e14b7a532154409 (diff)
Move pcap rx/tx trace code out of the dpdk plugin
Moved code to the ethernet input node, and the interface output path(s). Since we no longer skip ethernet-input, there's no reason for device drivers to know anything about pcap rx tracing, etc. Change-Id: I08d32fb1b90cbee1bd4f609837d533e047b36fa4 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vnet/interface_output.c')
-rw-r--r--src/vnet/interface_output.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/vnet/interface_output.c b/src/vnet/interface_output.c
index 251ff34ac9a..6c2345be270 100644
--- a/src/vnet/interface_output.c
+++ b/src/vnet/interface_output.c
@@ -802,6 +802,43 @@ vnet_interface_output_node_inline_gso (vlib_main_t * vm,
return n_buffers;
}
+static_always_inline void vnet_interface_pcap_tx_trace
+ (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame,
+ int sw_if_index_from_buffer)
+{
+ u32 n_left_from, *from;
+ u32 sw_if_index;
+
+ if (PREDICT_TRUE (vm->pcap[VLIB_TX].pcap_enable == 0))
+ return;
+
+ if (sw_if_index_from_buffer == 0)
+ {
+ vnet_interface_output_runtime_t *rt = (void *) node->runtime_data;
+ sw_if_index = rt->sw_if_index;
+ }
+ else
+ sw_if_index = ~0;
+
+ n_left_from = frame->n_vectors;
+ from = vlib_frame_vector_args (frame);
+
+ while (n_left_from > 0)
+ {
+ u32 bi0 = from[0];
+ vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0);
+
+ if (sw_if_index_from_buffer)
+ sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX];
+
+ if (vm->pcap[VLIB_TX].pcap_sw_if_index == 0 ||
+ vm->pcap[VLIB_TX].pcap_sw_if_index == sw_if_index)
+ pcap_add_buffer (&vm->pcap[VLIB_TX].pcap_main, vm, bi0, 512);
+ from++;
+ n_left_from--;
+ }
+}
+
static_always_inline uword
vnet_interface_output_node_inline (vlib_main_t * vm,
vlib_node_runtime_t * node,
@@ -809,6 +846,9 @@ vnet_interface_output_node_inline (vlib_main_t * vm,
vnet_hw_interface_t * hi,
int do_tx_offloads)
{
+ vnet_interface_pcap_tx_trace (vm, node, frame,
+ 0 /* sw_if_index_from_buffer */ );
+
/*
* The 3-headed "if" is here because we want to err on the side
* of not impacting the non-GSO performance - so for the more
@@ -838,6 +878,9 @@ vnet_interface_output_node (vlib_main_t * vm, vlib_node_runtime_t * node,
vnet_interface_output_runtime_t *rt = (void *) node->runtime_data;
hi = vnet_get_sup_hw_interface (vnm, rt->sw_if_index);
+ vnet_interface_pcap_tx_trace (vm, node, frame,
+ 0 /* sw_if_index_from_buffer */ );
+
if (hi->flags & VNET_HW_INTERFACE_FLAG_SUPPORTS_TX_L4_CKSUM_OFFLOAD)
return vnet_interface_output_node_inline (vm, node, frame, vnm, hi,
/* do_tx_offloads */ 0);
@@ -856,6 +899,9 @@ vnet_per_buffer_interface_output (vlib_main_t * vm,
u32 n_left_to_next, *from, *to_next;
u32 n_left_from, next_index;
+ vnet_interface_pcap_tx_trace (vm, node, frame,
+ 1 /* sw_if_index_from_buffer */ );
+
n_left_from = frame->n_vectors;
from = vlib_frame_vector_args (frame);