diff options
author | Dave Barach <dbarach@cisco.com> | 2018-05-25 17:36:05 -0400 |
---|---|---|
committer | Dave Barach <dbarach@cisco.com> | 2018-05-25 17:36:44 -0400 |
commit | c6f186b23d00685b3e9f132ba79a5cb44f0a44c0 (patch) | |
tree | cddcc7b7831e61f0f5d7b008a7ca1ae80e14f280 /src/plugins/dpdk/device/node.c | |
parent | c65770deebf63d34cc09c6aa3af7c86b3affb4b8 (diff) |
Add interface rx pcap tracing
Should cost at most 1 clock per frame when not enabled.
Add "pcap rx trace..." debug CLI, refactored "pcap tx trace" debug CLI
to avoid duplicating code.
Change-Id: I19ac75d1cf94a6a24c98facbf0753381d37963ea
Signed-off-by: Dave Barach <dbarach@cisco.com>
Diffstat (limited to 'src/plugins/dpdk/device/node.c')
-rw-r--r-- | src/plugins/dpdk/device/node.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/plugins/dpdk/device/node.c b/src/plugins/dpdk/device/node.c index a1acc1f0d1e..daccf733372 100644 --- a/src/plugins/dpdk/device/node.c +++ b/src/plugins/dpdk/device/node.c @@ -553,7 +553,7 @@ dpdk_device_input (vlib_main_t * vm, dpdk_main_t * dm, dpdk_device_t * xd, n_rx_packets); /* packet trace if enabled */ - if ((n_trace = vlib_get_trace_count (vm, node))) + if (PREDICT_FALSE ((n_trace = vlib_get_trace_count (vm, node)))) { n_left = n_rx_packets; buffers = ptd->buffers; @@ -584,6 +584,48 @@ dpdk_device_input (vlib_main_t * vm, dpdk_main_t * dm, dpdk_device_t * xd, vlib_set_trace_count (vm, node, n_trace); } + /* rx pcap capture if enabled */ + if (PREDICT_FALSE (dm->pcap[VLIB_RX].pcap_enable)) + { + u32 bi0; + n_left = n_rx_packets; + buffers = ptd->buffers; + while (n_left) + { + bi0 = buffers[0]; + b0 = vlib_get_buffer (vm, bi0); + buffers++; + + if (dm->pcap[VLIB_RX].pcap_sw_if_index == 0 || + dm->pcap[VLIB_RX].pcap_sw_if_index + == vnet_buffer (b0)->sw_if_index[VLIB_RX]) + { + struct rte_mbuf *mb; + i16 data_start; + i32 temp_advance; + + /* + * Note: current_data will have advanced + * when we skip ethernet input. + * Temporarily back up to the original DMA + * target, so we capture a valid ethernet frame + */ + mb = rte_mbuf_from_vlib_buffer (b0); + + /* Figure out the original data_start */ + data_start = (mb->buf_addr + mb->data_off) - (void *) b0->data; + /* Back up that far */ + temp_advance = b0->current_data - data_start; + vlib_buffer_advance (b0, -temp_advance); + /* Trace the packet */ + pcap_add_buffer (&dm->pcap[VLIB_RX].pcap_main, vm, bi0, 512); + /* and advance again */ + vlib_buffer_advance (b0, temp_advance); + } + n_left--; + } + } + vlib_increment_combined_counter (vnet_get_main ()->interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, thread_index, xd->sw_if_index, |