test-pmd: add more packet decode options (verbose)
PATCH 1/1 test-pmd: add more packet decode options (verbose)
The existing verbose levels 1..3 provide a messy multi-line output per packet. This is unhelpful when diagnosing many types of problems like packet flow.
This patch adds two new levels:
4: one line per packet is printed in a format resembling
tshark output. With addresses and protocol info.
5: dump packet in hex.
Useful if the driver is messing up the data.
--- app/test-pmd/cmdline_flow.c | 3 +- app/test-pmd/config.c | 33 +- app/test-pmd/testpmd.h | 11 + app/test-pmd/util.c | 355 +++++++++++++++++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- 5 files changed, 391 insertions(+), 16 deletions(-)
app/test-pmd/cmdline_flow.c +2 -1
@@ -14002,7 +14002,8 @@ cmd_set_raw_parsed(const struct buffer *in) upper_layer = proto; } } -if (verbose_level &0x1 ) + +if (verbose_level >0 )printf ("total data size is %zu\n" , (*total_size));RTE_ASSERT ((*total_size) <=ACTION_RAW_ENCAP_MAX_DATA );memmove (data, (data_tail - (*total_size)), *total_size);
app/test-pmd/config.c +22 -11
@@ -6250,26 +6250,37 @@ configure_rxtx_dump_callbacks(uint16_t verbose)return ;#endif -RTE_ETH_FOREACH_DEV (portid) - { -if (verbose ==1 || verbose >2 ) +RTE_ETH_FOREACH_DEV (portid) { +switch (verbose) { +case VERBOSE_OFF : +remove_rx_dump_callbacks (portid); +remove_tx_dump_callbacks (portid); +break ; +case VERBOSE_RX :add_rx_dump_callbacks (portid); -else +remove_tx_dump_callbacks (portid); +break ; +case VERBOSE_TX : +add_tx_dump_callbacks (portid);remove_rx_dump_callbacks (portid); -if (verbose >=2 ) +break ; +default : +add_rx_dump_callbacks (portid);add_tx_dump_callbacks (portid); -else -remove_tx_dump_callbacks (portid); + } } }void set_verbose_level (uint16_t vb_level) { -printf ("Change verbose level from %u to %u\n" , - (unsigned int ) verbose_level, (unsigned int ) vb_level); - verbose_level = vb_level; -configure_rxtx_dump_callbacks (verbose_level); +if (vb_level <VERBOSE_MAX ) { +printf ("Change verbose level from %u to %u\n" , verbose_level, vb_level); + verbose_level = vb_level; +configure_rxtx_dump_callbacks (verbose_level); + }else { +fprintf (stderr,"Verbose level %u is out of range\n" , vb_level); + } }void
app/test-pmd/testpmd.h +11 -0
@@ -489,6 +489,17 @@ enum dcb_mode_enableextern uint8_t xstats_hide_zero;/**< Hide zero values for xstats display */ +enum verbose_mode { +VERBOSE_OFF =0 , +VERBOSE_RX , +VERBOSE_TX , +VERBOSE_BOTH , +VERBOSE_DISSECT , +VERBOSE_HEX , +VERBOSE_MAX +}; + +/* globals used for configuration */ extern uint8_t record_core_cycles;/**< Enables measurement of CPU cycles */ extern uint8_t record_burst_stats;/**< Enables display of RX and TX bursts */
app/test-pmd/util.c +352 -3
379 lines not on this page · raw message
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -1
@@ -677,7 +677,10 @@ Available levels are as following: * ``0`` silent except for error. * ``1`` fully verbose except for Tx packets. * ``2`` fully verbose except for Rx packets. -* ``> 2`` fully verbose. +* ``3`` fully verbose except for Tx and Rx packets. +* ``4`` dissected protocol information for Tx and Rx packets. +* ``5`` hex dump of packets + set log ~~~~~~~
Signature · 1 line
2.43.0
Quoted 11 lines · On Tue, 12 Mar 2024 15:01:27 -0700 Stephen Hemminger…
The existing verbose levels 1..3 provide a messy multi-line output per packet. This is unhelpful when diagnosing many types of problems like packet flow.
This patch adds two new levels:
4: one line per packet is printed in a format resembling
tshark output. With addresses and protocol info.
5: dump packet in hex.
Useful if the driver is messing up the data.Signed-off-by Stephen Hemminger <[email protected]>
The build on mingw (ie. GCC on Windows) fails because of mismatch in the function prototype. It is already fixed upstream in mingw could the CI infrastructure please be updated.
The commit upstream that fixed the bug was almost 5 years ago.
commit 1b5ae4b567ee1699f69cd918ae2bc693898edbb2
Author: Martin Storsjö <[email protected]> Date: Mon Apr 22 15:09:14 2019 +0300
headers: Use proper types for InetNtopA/W
PCVOID is not commonly defined, only LPCVOID.
This commit is in the 7.0 release.
The current version of MinGw is 11.0 which is what CI should be using!
Unfortunately, DPDK documentation and build does not have a version listed.
Quoted 5 lines · Stephen Hemminger
The existing verbose levels 1..3 provide a messy multi-line output per packet. This is unhelpful when diagnosing many types of problems like packet flow.
Quoted 7 lines
This patch adds two new levels:
4: one line per packet is printed in a format resembling
tshark output. With addresses and protocol info.
5: dump packet in hex.
Useful if the driver is messing up the data.Signed-off-by Stephen Hemminger <[email protected]>
That's an interesting addition.
I like the tshark like output.
I had to write similar (more limited) parsing for debug.
I know some project decodes packets and it could probably reuse what DPDK provides.
Could the parsing function you propose go to lib/net/ maybe? Something like rte_net_format_packet(const struct rte_mbuf *m, char *buf, size_t size);
It could be worth instructing the parser to decode only a part of the packet too (via an offset/size and a hint of the layer).
An additional comment: when you have multiple cores processing packets (even at low rate), getting all those output mixed with no context at all would be hard to follow.
I would prefer we retain the information of whether the displayed packet was caught on Rx/Tx and the queue and port on which it happened.
As an alternative, there is the possibility of only displaying received or transmitted packets (if verbose is used as a bitmask with 0x1 and 0x2 controlling rx / tx filtering, and the new modes enhancing output beauty).
Signature · 1 line
David Marchand
v2 cover Add packet dissector
In reply to Stephen HemmingerTake earlier patch which enhanced mbuf printout for test-pmd and generalize this to be a function in net library.
v2 - splits the patch up and adds standalone functional tests
Stephen Hemminger (3):
net: add new packet dissector
test: add test for packet dissector
test-pmd: add more packet verbose decode options
app/test-pmd/cmdline_flow.c | 3 +- app/test-pmd/config.c | 33 +- app/test-pmd/testpmd.h | 11 + app/test-pmd/util.c | 71 +++- app/test/meson.build | 1 + app/test/test_dissect.c | 289 ++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- lib/net/meson.build | 2 + lib/net/rte_dissect.c | 357 ++++++++++++++++++++ lib/net/rte_dissect.h | 40 +++ lib/net/version.map | 7 + 11 files changed, 801 insertions(+), 18 deletions(-) create mode 100644 app/test/test_dissect.c create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
Signature · 1 line
2.43.0
PATCH v2 1/3 net: add new packet dissector
The function rte_dissect_mbuf is used to decode the contents of an mbuf and print them in human readable format similar to what tshark uses.
For now, handles IP, IPv6, TCP, UDP, ICMP and ARP. The intention is to extend this to be able to handle more nested tunnel types as well as higher level protocols such as DNS and HTTP.
--- lib/net/meson.build | 2 + lib/net/rte_dissect.c | 357 ++++++++++++++++++++++++++++++++++++++++++ lib/net/rte_dissect.h | 40 +++++ lib/net/version.map | 7 + 4 files changed, 406 insertions(+) create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
lib/net/meson.build +2 -0
@@ -2,6 +2,7 @@ # Copyright(c) 2017-2020 Intel Corporation headers = files( + 'rte_dissect.h', 'rte_ip.h', 'rte_tcp.h', 'rte_udp.h',
@@ -30,6 +31,7 @@ headers = files( sources = files( 'rte_arp.c', + 'rte_dissect.c', 'rte_ether.c', 'rte_net.c', 'rte_net_crc.c',
lib/net/rte_dissect.c new file +357 -0
357 lines not on this page · raw message
lib/net/rte_dissect.h new file +40 -0
@@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 Stephen Hemminger <[email protected]> +*/ + +#ifndef _RTE_NET_DISSECT_H_ +#define _RTE_NET_DISSECT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdio.h> +#include <stdint.h> + +#include <rte_compat.h> + +struct rte_mbuf ; + +/** +* +* Print packets in format (single line) similar to tshark to a file. +* +* @param f +* A pointer to a file for output +* @param m +* The packet mbuf. +* @param dump_len +* Maximum offset in packet to examine. +* If is zero then dump the whole packet. +*/ +__rte_experimental +void +rte_dissect_mbuf (FILE *f,const struct rte_mbuf *m,uint32_t dump_len); + +#ifdef __cplusplus +} +#endif + + +#endif /* _RTE_NET_DISSECT_H_ */
lib/net/version.map +7 -0
@@ -12,3 +12,10 @@ DPDK_24 { local: *; }; + +EXPERIMENTAL { + global: + + # added in 24.11 + rte_dissect_mbuf; +};
Signature · 1 line
2.43.0
PATCH v2 2/3 test: add test for packet dissector
In reply to Stephen HemmingerSome tests for new packet dissector.
--- app/test/meson.build | 1 + app/test/test_dissect.c | 289 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 290 insertions(+) create mode 100644 app/test/test_dissect.c
app/test/meson.build +1 -0
@@ -62,6 +62,7 @@ source_file_deps = { 'test_debug.c': [], 'test_devargs.c': ['kvargs'], 'test_dispatcher.c': ['dispatcher'], + 'test_dissect.c': ['net'], 'test_distributor.c': ['distributor'], 'test_distributor_perf.c': ['distributor'], 'test_dmadev.c': ['dmadev', 'bus_vdev'],
app/test/test_dissect.c new file +289 -0
289 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 3/3 test-pmd: add more packet verbose decode options
In reply to Stephen HemmingerThe existing verbose levels 1..3 provide a messy multi-line output per packet. I found this unhelpful when diagnosing many types of problems like packet flow.
This patch keeps the previous levels and adds two new levels:
4: one line per packet is printed in a format resembling
tshark output. With addresses and protocol info.
5: dump packet in hex.
Useful if the driver is messing up the data.
--- app/test-pmd/cmdline_flow.c | 3 +- app/test-pmd/config.c | 33 ++++++---- app/test-pmd/testpmd.h | 11 ++++ app/test-pmd/util.c | 71 +++++++++++++++++++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- 5 files changed, 105 insertions(+), 18 deletions(-)
app/test-pmd/cmdline_flow.c +2 -1
@@ -14076,7 +14076,8 @@ cmd_set_raw_parsed(const struct buffer *in) upper_layer = proto; } } -if (verbose_level &0x1 ) + +if (verbose_level >0 )printf ("total data size is %zu\n" , (*total_size));RTE_ASSERT ((*total_size) <=ACTION_RAW_ENCAP_MAX_DATA );memmove (data, (data_tail - (*total_size)), *total_size);
app/test-pmd/config.c +22 -11
@@ -6246,26 +6246,37 @@ configure_rxtx_dump_callbacks(uint16_t verbose)return ;#endif -RTE_ETH_FOREACH_DEV (portid) - { -if (verbose ==1 || verbose >2 ) +RTE_ETH_FOREACH_DEV (portid) { +switch (verbose) { +case VERBOSE_OFF : +remove_rx_dump_callbacks (portid); +remove_tx_dump_callbacks (portid); +break ; +case VERBOSE_RX :add_rx_dump_callbacks (portid); -else +remove_tx_dump_callbacks (portid); +break ; +case VERBOSE_TX : +add_tx_dump_callbacks (portid);remove_rx_dump_callbacks (portid); -if (verbose >=2 ) +break ; +default : +add_rx_dump_callbacks (portid);add_tx_dump_callbacks (portid); -else -remove_tx_dump_callbacks (portid); + } } }void set_verbose_level (uint16_t vb_level) { -printf ("Change verbose level from %u to %u\n" , - (unsigned int ) verbose_level, (unsigned int ) vb_level); - verbose_level = vb_level; -configure_rxtx_dump_callbacks (verbose_level); +if (vb_level <VERBOSE_MAX ) { +printf ("Change verbose level from %u to %u\n" , verbose_level, vb_level); + verbose_level = vb_level; +configure_rxtx_dump_callbacks (verbose_level); + }else { +fprintf (stderr,"Verbose level %u is out of range\n" , vb_level); + } }void
app/test-pmd/testpmd.h +11 -0
@@ -489,6 +489,17 @@ enum dcb_mode_enableextern uint8_t xstats_hide_zero;/**< Hide zero values for xstats display */ +enum verbose_mode { +VERBOSE_OFF =0 , +VERBOSE_RX , +VERBOSE_TX , +VERBOSE_BOTH , +VERBOSE_DISSECT , +VERBOSE_HEX , +VERBOSE_MAX +}; + +/* globals used for configuration */ extern uint8_t record_core_cycles;/**< Enables measurement of CPU cycles */ extern uint8_t record_burst_stats;/**< Enables display of RX and TX bursts */
app/test-pmd/util.c +66 -5
101 lines not on this page · raw message
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -1
@@ -676,7 +676,10 @@ Available levels are as following: * ``0`` silent except for error. * ``1`` fully verbose except for Tx packets. * ``2`` fully verbose except for Rx packets. -* ``> 2`` fully verbose. +* ``3`` fully verbose except for Tx and Rx packets. +* ``4`` dissected protocol information for Tx and Rx packets. +* ``5`` hex dump of packets + set log ~~~~~~~
Signature · 1 line
2.43.0
v3 cover add packet dissector function
In reply to Stephen HemmingerWhile debugging TAP rte_flow discovered that test pmd verbose output was confusing and unhelpful. Instead, made a simple dissector that prints one line per packet like this in test-pmd with verbose level 4
Seq# Time Port:Que Description
1 0.000000000 0:0 :: → ff02::16 ICMP 143
2 0.000000000 0:0 :: → ff02::1:ff98:2b46 ICMP 135 36 0.512762002 0:0 fe80::285f:1fff:fe98:2b46 → ff02::fb UDP 120 5353 → 5353
37 0.512779925 0:0 fe80::285f:1fff:fe98:2b46 → ff02::fb UDP 120 5353 → 5353v3 - use a string buffer instead of use stdio stream
because that can get garbled when dealing with multiple threads.
- don't use longjmp unwind, as it can lead to bugs later.
Stephen Hemminger (3):
net: add new packet dissector
test: add test for packet dissector
test-pmd: add more packet verbose decode options
app/test-pmd/cmdline_flow.c | 3 +- app/test-pmd/config.c | 33 +- app/test-pmd/testpmd.h | 11 + app/test-pmd/util.c | 77 +++- app/test/meson.build | 1 + app/test/test_dissect.c | 241 ++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- lib/net/meson.build | 2 + lib/net/rte_dissect.c | 407 ++++++++++++++++++++ lib/net/rte_dissect.h | 42 ++ lib/net/version.map | 7 + 11 files changed, 811 insertions(+), 18 deletions(-) create mode 100644 app/test/test_dissect.c create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
Signature · 1 line
2.43.0
PATCH v3 1/3 net: add new packet dissector
The function rte_dissect_mbuf is used to decode the contents of an mbuf into ah uman readable format similar to what tshark uses.
For now, handles IP, IPv6, TCP, UDP, ICMP and ARP.
--- lib/net/meson.build | 2 + lib/net/rte_dissect.c | 407 ++++++++++++++++++++++++++++++++++++++++++ lib/net/rte_dissect.h | 42 +++++ lib/net/version.map | 7 + 4 files changed, 458 insertions(+) create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
lib/net/meson.build +2 -0
@@ -2,6 +2,7 @@ # Copyright(c) 2017-2020 Intel Corporation headers = files( + 'rte_dissect.h', 'rte_ip.h', 'rte_tcp.h', 'rte_udp.h',
@@ -30,6 +31,7 @@ headers = files( sources = files( 'rte_arp.c', + 'rte_dissect.c', 'rte_ether.c', 'rte_net.c', 'rte_net_crc.c',
lib/net/rte_dissect.c new file +407 -0
407 lines not on this page · raw message
lib/net/rte_dissect.h new file +42 -0
42 lines not on this page · raw message
lib/net/version.map +7 -0
@@ -12,3 +12,10 @@ DPDK_24 { local: *; }; + +EXPERIMENTAL { + global: + + # added in 24.11 + rte_dissect_mbuf; +};
Signature · 1 line
2.43.0
PATCH v3 2/3 test: add test for packet dissector
In reply to Stephen HemmingerSome tests for new packet dissector.
--- app/test/meson.build | 1 + app/test/test_dissect.c | 241 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 app/test/test_dissect.c
app/test/meson.build +1 -0
@@ -62,6 +62,7 @@ source_file_deps = { 'test_debug.c': [], 'test_devargs.c': ['kvargs'], 'test_dispatcher.c': ['dispatcher'], + 'test_dissect.c': ['net'], 'test_distributor.c': ['distributor'], 'test_distributor_perf.c': ['distributor'], 'test_dmadev.c': ['dmadev', 'bus_vdev'],
app/test/test_dissect.c new file +241 -0
241 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v3 3/3 test-pmd: add more packet verbose decode options
In reply to Stephen HemmingerThe existing verbose levels 1..3 provide a messy multi-line output per packet. I found this unhelpful when diagnosing many types of problems like packet flow.
This patch keeps the previous levels and adds two new levels:
4: one line per packet is printed in a format resembling
tshark output. With addresses and protocol info.
5: dump packet in hex.
Useful if the driver is messing up the data.
--- app/test-pmd/cmdline_flow.c | 3 +- app/test-pmd/config.c | 33 ++++++--- app/test-pmd/testpmd.h | 11 +++ app/test-pmd/util.c | 77 +++++++++++++++++++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- 5 files changed, 111 insertions(+), 18 deletions(-)
app/test-pmd/cmdline_flow.c +2 -1
@@ -14076,7 +14076,8 @@ cmd_set_raw_parsed(const struct buffer *in) upper_layer = proto; } } -if (verbose_level &0x1 ) + +if (verbose_level >0 )printf ("total data size is %zu\n" , (*total_size));RTE_ASSERT ((*total_size) <=ACTION_RAW_ENCAP_MAX_DATA );memmove (data, (data_tail - (*total_size)), *total_size);
app/test-pmd/config.c +22 -11
@@ -6246,26 +6246,37 @@ configure_rxtx_dump_callbacks(uint16_t verbose)return ;#endif -RTE_ETH_FOREACH_DEV (portid) - { -if (verbose ==1 || verbose >2 ) +RTE_ETH_FOREACH_DEV (portid) { +switch (verbose) { +case VERBOSE_OFF : +remove_rx_dump_callbacks (portid); +remove_tx_dump_callbacks (portid); +break ; +case VERBOSE_RX :add_rx_dump_callbacks (portid); -else +remove_tx_dump_callbacks (portid); +break ; +case VERBOSE_TX : +add_tx_dump_callbacks (portid);remove_rx_dump_callbacks (portid); -if (verbose >=2 ) +break ; +default : +add_rx_dump_callbacks (portid);add_tx_dump_callbacks (portid); -else -remove_tx_dump_callbacks (portid); + } } }void set_verbose_level (uint16_t vb_level) { -printf ("Change verbose level from %u to %u\n" , - (unsigned int ) verbose_level, (unsigned int ) vb_level); - verbose_level = vb_level; -configure_rxtx_dump_callbacks (verbose_level); +if (vb_level <VERBOSE_MAX ) { +printf ("Change verbose level from %u to %u\n" , verbose_level, vb_level); + verbose_level = vb_level; +configure_rxtx_dump_callbacks (verbose_level); + }else { +fprintf (stderr,"Verbose level %u is out of range\n" , vb_level); + } }void
app/test-pmd/testpmd.h +11 -0
@@ -489,6 +489,17 @@ enum dcb_mode_enableextern uint8_t xstats_hide_zero;/**< Hide zero values for xstats display */ +enum verbose_mode { +VERBOSE_OFF =0 , +VERBOSE_RX , +VERBOSE_TX , +VERBOSE_BOTH , +VERBOSE_DISSECT , +VERBOSE_HEX , +VERBOSE_MAX +}; + +/* globals used for configuration */ extern uint8_t record_core_cycles;/**< Enables measurement of CPU cycles */ extern uint8_t record_burst_stats;/**< Enables display of RX and TX bursts */
app/test-pmd/util.c +72 -5
110 lines not on this page · raw message
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -1
@@ -676,7 +676,10 @@ Available levels are as following: * ``0`` silent except for error. * ``1`` fully verbose except for Tx packets. * ``2`` fully verbose except for Rx packets. -* ``> 2`` fully verbose. +* ``3`` fully verbose except for Tx and Rx packets. +* ``4`` dissected protocol information for Tx and Rx packets. +* ``5`` hex dump of packets + set log ~~~~~~~
Signature · 1 line
2.43.0
v4 cover Add packet dissector
In reply to Stephen HemmingerWhile debugging TAP rte_flow discovered that test pmd verbose output was confusing and unhelpful. Instead, made a simple dissector that prints one line per packet like this in test-pmd with verbose level 4.
Seq# Time Port:Que R Description
1 0.000000000 0:0 R :: → ff02::16 ICMP 143
2 0.000000000 0:0 R :: → ff02::1:ffbc:89e5 ICMP 135
3 0.000000000 0:0 R :: → ff02::16 ICMP 143
...
38 0.313868235 0:0 T fe80::7442:55ff:febc:89e5 → ff02::fb UDP 70 5353 → 5353
39 4.635121071 0:0 R fe80::7442:55ff:febc:89e5 → ff02::2 ICMPv6 Router Solicitation
40 4.635138535 0:0 T fe80::7442:55ff:febc:89e5 → ff02::2 ICMPv6 Router Solicitationv4 - add direction flag to output
- fix build on Windows
Stephen Hemminger (3):
net: add new packet dissector
test: add test for packet dissector
test-pmd: add more packet verbose decode options
app/test-pmd/cmdline_flow.c | 3 +- app/test-pmd/config.c | 33 +- app/test-pmd/testpmd.h | 11 + app/test-pmd/util.c | 77 +++- app/test/meson.build | 1 + app/test/test_dissect.c | 245 ++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- lib/net/meson.build | 2 + lib/net/rte_dissect.c | 404 ++++++++++++++++++++ lib/net/rte_dissect.h | 42 ++ lib/net/version.map | 7 + 11 files changed, 812 insertions(+), 18 deletions(-) create mode 100644 app/test/test_dissect.c create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
Signature · 1 line
2.43.0
PATCH v4 1/3 net: add new packet dissector
The function rte_dissect_mbuf is used to decode the contents of an mbuf into ah uman readable format similar to what tshark uses.
For now, handles IP, IPv6, TCP, UDP, ICMP and ARP.
--- lib/net/meson.build | 2 + lib/net/rte_dissect.c | 404 ++++++++++++++++++++++++++++++++++++++++++ lib/net/rte_dissect.h | 42 +++++ lib/net/version.map | 7 + 4 files changed, 455 insertions(+) create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
lib/net/meson.build +2 -0
@@ -2,6 +2,7 @@ # Copyright(c) 2017-2020 Intel Corporation headers = files( + 'rte_dissect.h', 'rte_ip.h', 'rte_tcp.h', 'rte_udp.h',
@@ -30,6 +31,7 @@ headers = files( sources = files( 'rte_arp.c', + 'rte_dissect.c', 'rte_ether.c', 'rte_net.c', 'rte_net_crc.c',
lib/net/rte_dissect.c new file +404 -0
404 lines not on this page · raw message
lib/net/rte_dissect.h new file +42 -0
42 lines not on this page · raw message
lib/net/version.map +7 -0
@@ -12,3 +12,10 @@ DPDK_24 { local: *; }; + +EXPERIMENTAL { + global: + + # added in 24.11 + rte_dissect_mbuf; +};
Signature · 1 line
2.43.0
PATCH v4 2/3 test: add test for packet dissector
In reply to Stephen HemmingerSome tests for new packet dissector.
--- app/test/meson.build | 1 + app/test/test_dissect.c | 245 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 246 insertions(+) create mode 100644 app/test/test_dissect.c
app/test/meson.build +1 -0
@@ -62,6 +62,7 @@ source_file_deps = { 'test_debug.c': [], 'test_devargs.c': ['kvargs'], 'test_dispatcher.c': ['dispatcher'], + 'test_dissect.c': ['net'], 'test_distributor.c': ['distributor'], 'test_distributor_perf.c': ['distributor'], 'test_dmadev.c': ['dmadev', 'bus_vdev'],
app/test/test_dissect.c new file +245 -0
245 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v4 3/3 test-pmd: add more packet verbose decode options
In reply to Stephen HemmingerThe existing verbose levels 1..3 provide a messy multi-line output per packet. I found this unhelpful when diagnosing many types of problems like packet flow.
This patch keeps the previous levels and adds two new levels:
4: one line per packet is printed in a format resembling
tshark output. With addresses and protocol info.
5: dump packet in hex.
Useful if the driver is messing up the data.
--- app/test-pmd/cmdline_flow.c | 3 +- app/test-pmd/config.c | 33 ++++++--- app/test-pmd/testpmd.h | 11 +++ app/test-pmd/util.c | 77 +++++++++++++++++++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- 5 files changed, 111 insertions(+), 18 deletions(-)
app/test-pmd/cmdline_flow.c +2 -1
@@ -14143,7 +14143,8 @@ cmd_set_raw_parsed(const struct buffer *in) upper_layer = proto; } } -if (verbose_level &0x1 ) + +if (verbose_level >0 )printf ("total data size is %zu\n" , (*total_size));RTE_ASSERT ((*total_size) <=ACTION_RAW_ENCAP_MAX_DATA );memmove (data, (data_tail - (*total_size)), *total_size);
app/test-pmd/config.c +22 -11
@@ -6246,26 +6246,37 @@ configure_rxtx_dump_callbacks(uint16_t verbose)return ;#endif -RTE_ETH_FOREACH_DEV (portid) - { -if (verbose ==1 || verbose >2 ) +RTE_ETH_FOREACH_DEV (portid) { +switch (verbose) { +case VERBOSE_OFF : +remove_rx_dump_callbacks (portid); +remove_tx_dump_callbacks (portid); +break ; +case VERBOSE_RX :add_rx_dump_callbacks (portid); -else +remove_tx_dump_callbacks (portid); +break ; +case VERBOSE_TX : +add_tx_dump_callbacks (portid);remove_rx_dump_callbacks (portid); -if (verbose >=2 ) +break ; +default : +add_rx_dump_callbacks (portid);add_tx_dump_callbacks (portid); -else -remove_tx_dump_callbacks (portid); + } } }void set_verbose_level (uint16_t vb_level) { -printf ("Change verbose level from %u to %u\n" , - (unsigned int ) verbose_level, (unsigned int ) vb_level); - verbose_level = vb_level; -configure_rxtx_dump_callbacks (verbose_level); +if (vb_level <VERBOSE_MAX ) { +printf ("Change verbose level from %u to %u\n" , verbose_level, vb_level); + verbose_level = vb_level; +configure_rxtx_dump_callbacks (verbose_level); + }else { +fprintf (stderr,"Verbose level %u is out of range\n" , vb_level); + } }void
app/test-pmd/testpmd.h +11 -0
@@ -489,6 +489,17 @@ enum dcb_mode_enableextern uint8_t xstats_hide_zero;/**< Hide zero values for xstats display */ +enum verbose_mode { +VERBOSE_OFF =0 , +VERBOSE_RX , +VERBOSE_TX , +VERBOSE_BOTH , +VERBOSE_DISSECT , +VERBOSE_HEX , +VERBOSE_MAX +}; + +/* globals used for configuration */ extern uint8_t record_core_cycles;/**< Enables measurement of CPU cycles */ extern uint8_t record_burst_stats;/**< Enables display of RX and TX bursts */
app/test-pmd/util.c +72 -5
110 lines not on this page · raw message
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -1
@@ -677,7 +677,10 @@ Available levels are as following: * ``0`` silent except for error. * ``1`` fully verbose except for Tx packets. * ``2`` fully verbose except for Rx packets. -* ``> 2`` fully verbose. +* ``3`` fully verbose except for Tx and Rx packets. +* ``4`` dissected protocol information for Tx and Rx packets. +* ``5`` hex dump of packets + set log ~~~~~~~
Signature · 1 line
2.43.0
v5 cover Add network packet dissector
In reply to Stephen HemmingerWhile debugging TAP rte_flow discovered that test pmd verbose output was confusing and unhelpful. Instead, made a simple dissector that prints one line per packet like this in test-pmd with verbose level 4.
v5 - breakout the additional ICMP types into header
- fix some decoding bugs in ARP and ICMP
Stephen Hemminger (4):
net: add more icmp types
net: add new packet dissector
test: add test for packet dissector
test-pmd: add more packet verbose decode options
app/test-pmd/cmdline_flow.c | 3 +- app/test-pmd/config.c | 33 +- app/test-pmd/testpmd.h | 11 + app/test-pmd/util.c | 77 +++- app/test/meson.build | 1 + app/test/test_dissect.c | 245 ++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- lib/net/meson.build | 2 + lib/net/rte_dissect.c | 416 ++++++++++++++++++++ lib/net/rte_dissect.h | 42 ++ lib/net/rte_icmp.h | 22 +- lib/net/version.map | 7 + 12 files changed, 842 insertions(+), 22 deletions(-) create mode 100644 app/test/test_dissect.c create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
Signature · 1 line
2.43.0
PATCH v5 1/4 net: add more icmp types
Add more defines for additional defined ICMP types.
--- lib/net/rte_icmp.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
lib/net/rte_icmp.h +18 -4
@@ -54,10 +54,24 @@ struct rte_icmp_hdr { } __rte_packed;/* ICMP packet types */ -#define RTE_IP_ICMP_ECHO_REPLY 0 -#define RTE_IP_ICMP_ECHO_REQUEST 8 -#define RTE_ICMP6_ECHO_REQUEST 128 -#define RTE_ICMP6_ECHO_REPLY 129 +#define RTE_IP_ICMP_ECHO_REPLY 0 +#define RTE_IP_ICMP_DEST_UNREACH 3 +#define RTE_IP_ICMP_SOURCE_QUENCH 4 +#define RTE_IP_ICMP_REDIRECT 5 +#define RTE_IP_ICMP_ECHO_REQUEST 8 +#define RTE_IP_ICMP_TIME_EXCEEDED 11 +#define RTE_IP_ICMP_PARAMETERPROB 12 +#define RTE_IP_ICMP_TIMESTAMP 13 +#define RTE_IP_ICMP_TIMESTAMPREPLY 14 +#define RTE_IP_ICMP_INFO_REQUEST 15 +#define RTE_IP_ICMP_INFO_REPLY 16 + +#define RTE_ICMP6_ECHO_REQUEST 128 +#define RTE_ICMP6_ECHO_REPLY 129 +#define RTE_ND_ROUTER_SOLICIT 133 +#define RTE_ND_ROUTER_ADVERT 134 +#define RTE_ND_NEIGHBOR_SOLICIT 135 +#define RTE_ND_NEIGHBOR_ADVERT 136 #ifdef __cplusplus }
Signature · 1 line
2.43.0
PATCH v5 2/4 net: add new packet dissector
In reply to Stephen HemmingerThe function rte_dissect_mbuf is used to decode the contents of an mbuf into ah uman readable format similar to what tshark uses.
For now, handles IP, IPv6, TCP, UDP, ICMP and ARP.
--- lib/net/meson.build | 2 + lib/net/rte_dissect.c | 416 ++++++++++++++++++++++++++++++++++++++++++ lib/net/rte_dissect.h | 42 +++++ lib/net/version.map | 7 + 4 files changed, 467 insertions(+) create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
lib/net/meson.build +2 -0
@@ -2,6 +2,7 @@ # Copyright(c) 2017-2020 Intel Corporation headers = files( + 'rte_dissect.h', 'rte_ip.h', 'rte_tcp.h', 'rte_udp.h',
@@ -30,6 +31,7 @@ headers = files( sources = files( 'rte_arp.c', + 'rte_dissect.c', 'rte_ether.c', 'rte_net.c', 'rte_net_crc.c',
lib/net/rte_dissect.c new file +416 -0
416 lines not on this page · raw message
lib/net/rte_dissect.h new file +42 -0
42 lines not on this page · raw message
lib/net/version.map +7 -0
@@ -12,3 +12,10 @@ DPDK_24 { local: *; }; + +EXPERIMENTAL { + global: + + # added in 24.11 + rte_dissect_mbuf; +};
Signature · 1 line
2.43.0
PATCH v5 3/4 test: add test for packet dissector
In reply to Stephen HemmingerSome tests for new packet dissector.
--- app/test/meson.build | 1 + app/test/test_dissect.c | 245 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 246 insertions(+) create mode 100644 app/test/test_dissect.c
app/test/meson.build +1 -0
@@ -62,6 +62,7 @@ source_file_deps = { 'test_debug.c': [], 'test_devargs.c': ['kvargs'], 'test_dispatcher.c': ['dispatcher'], + 'test_dissect.c': ['net'], 'test_distributor.c': ['distributor'], 'test_distributor_perf.c': ['distributor'], 'test_dmadev.c': ['dmadev', 'bus_vdev'],
app/test/test_dissect.c new file +245 -0
245 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v5 3/4] test: add test for packet dissector
Quoted 26 lines · Stephen Hemminger
Some tests for new packet dissector.
Signed-off-by Stephen Hemminger <[email protected]>--- app/test/meson.build | 1 + app/test/test_dissect.c | 245 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 246 insertions(+) create mode 100644 app/test/test_dissect.capp/test/meson.build +1
-0@@ -62,6 +62,7 @@ source_file_deps = { 'test_debug.c': [], 'test_devargs.c': ['kvargs'], 'test_dispatcher.c': ['dispatcher'], + 'test_dissect.c': ['net'], 'test_distributor.c': ['distributor'], 'test_distributor_perf.c': ['distributor'], 'test_dmadev.c': ['dmadev', 'bus_vdev'],app/test/test_dissect.c new file +0
-0
<snip>
Quoted 9 lines
app/test/test_dissect.c new file +9
-0+static int +test_simple (void ) +{ +struct rte_mbuf mb; +uint8_t buf[RTE_MBUF_DEFAULT_BUF_SIZE ]; +uint32_t data_len =PACKET_LEN ; +uint16_t src_port =rte_rand (); +const uint16_t dst_port =rte_cpu_to_be_16 (9 );/* Discard port */ +char obuf[LINE_MAX ];
app/test/test_dissect.c line 161
Quoted 10 lines
app/test/test_dissect.c new file +10
-0+ +/* make a dummy packet */ +mbuf_prep (&mb, buf,sizeof (buf)); +add_header (&mb, data_len, src_port, dst_port); +fill_data (&mb, data_len - mb.data_off); + +rte_dissect_mbuf (obuf,sizeof (obuf), &mb,0 ); + +return TEST_SUCCESS ; +}
What are these test cases actually verifying - can any of them actually fail? I don't see the output being checked anywhere.
/Bruce
Re: [PATCH v5 3/4] test: add test for packet dissector
Quoted 2 lines · On Fri, 2 Aug 2024 09:38:23 +0100 Bruce Richardson…
What are these test cases actually verifying - can any of them actually fail? I don't see the output being checked anywhere.
Now that it returns a string could easily check expected result.
Re: [PATCH v5 3/4] test: add test for packet dissector
In reply to Bruce RichardsonQuoted 9 lines · On Fri, 2 Aug 2024 09:38:23 +0100 Bruce Richardson…
app/test/test_dissect.c line 161
Quoted 4 lines
app/test/test_dissect.c new file +4
-0+rte_dissect_mbuf (obuf,sizeof (obuf), &mb,0 ); + +return TEST_SUCCESS ; +}What are these test cases actually verifying - can any of them actually fail? I don't see the output being checked anywhere.
/Bruce
Mostly the tests are to make sure that code doesn't crash when given invalid packet data or truncated packet.
PATCH v5 4/4 test-pmd: add more packet verbose decode options
In reply to Stephen HemmingerThe existing verbose levels 1..3 provide a messy multi-line output per packet. I found this unhelpful when diagnosing many types of problems like packet flow.
This patch keeps the previous levels and adds two new levels:
4: one line per packet is printed in a format resembling
tshark output. With addresses and protocol info.
5: dump packet in hex.
Useful if the driver is messing up the data.
--- app/test-pmd/cmdline_flow.c | 3 +- app/test-pmd/config.c | 33 ++++++--- app/test-pmd/testpmd.h | 11 +++ app/test-pmd/util.c | 77 +++++++++++++++++++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- 5 files changed, 111 insertions(+), 18 deletions(-)
app/test-pmd/cmdline_flow.c +2 -1
@@ -14143,7 +14143,8 @@ cmd_set_raw_parsed(const struct buffer *in) upper_layer = proto; } } -if (verbose_level &0x1 ) + +if (verbose_level >0 )printf ("total data size is %zu\n" , (*total_size));RTE_ASSERT ((*total_size) <=ACTION_RAW_ENCAP_MAX_DATA );memmove (data, (data_tail - (*total_size)), *total_size);
app/test-pmd/config.c +22 -11
@@ -6246,26 +6246,37 @@ configure_rxtx_dump_callbacks(uint16_t verbose)return ;#endif -RTE_ETH_FOREACH_DEV (portid) - { -if (verbose ==1 || verbose >2 ) +RTE_ETH_FOREACH_DEV (portid) { +switch (verbose) { +case VERBOSE_OFF : +remove_rx_dump_callbacks (portid); +remove_tx_dump_callbacks (portid); +break ; +case VERBOSE_RX :add_rx_dump_callbacks (portid); -else +remove_tx_dump_callbacks (portid); +break ; +case VERBOSE_TX : +add_tx_dump_callbacks (portid);remove_rx_dump_callbacks (portid); -if (verbose >=2 ) +break ; +default : +add_rx_dump_callbacks (portid);add_tx_dump_callbacks (portid); -else -remove_tx_dump_callbacks (portid); + } } }void set_verbose_level (uint16_t vb_level) { -printf ("Change verbose level from %u to %u\n" , - (unsigned int ) verbose_level, (unsigned int ) vb_level); - verbose_level = vb_level; -configure_rxtx_dump_callbacks (verbose_level); +if (vb_level <VERBOSE_MAX ) { +printf ("Change verbose level from %u to %u\n" , verbose_level, vb_level); + verbose_level = vb_level; +configure_rxtx_dump_callbacks (verbose_level); + }else { +fprintf (stderr,"Verbose level %u is out of range\n" , vb_level); + } }void
app/test-pmd/testpmd.h +11 -0
@@ -489,6 +489,17 @@ enum dcb_mode_enableextern uint8_t xstats_hide_zero;/**< Hide zero values for xstats display */ +enum verbose_mode { +VERBOSE_OFF =0 , +VERBOSE_RX , +VERBOSE_TX , +VERBOSE_BOTH , +VERBOSE_DISSECT , +VERBOSE_HEX , +VERBOSE_MAX +}; + +/* globals used for configuration */ extern uint8_t record_core_cycles;/**< Enables measurement of CPU cycles */ extern uint8_t record_burst_stats;/**< Enables display of RX and TX bursts */
app/test-pmd/util.c +72 -5
110 lines not on this page · raw message
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -1
@@ -677,7 +677,10 @@ Available levels are as following: * ``0`` silent except for error. * ``1`` fully verbose except for Tx packets. * ``2`` fully verbose except for Rx packets. -* ``> 2`` fully verbose. +* ``3`` fully verbose except for Tx and Rx packets. +* ``4`` dissected protocol information for Tx and Rx packets. +* ``5`` hex dump of packets + set log ~~~~~~~
Signature · 1 line
2.43.0
v6 cover Add network packet dissector
In reply to Stephen HemmingerWhile debugging TAP rte_flow discovered that test pmd verbose output was confusing and unhelpful. Instead, made a simple dissector that prints one line per packet like this in test-pmd with verbose level 4.
v6 - validate result of rte_dissect for simple packet
v5 - breakout the additional ICMP types into header
- fix some decoding bugs in ARP and ICMP
Stephen Hemminger (4):
net: add more icmp types
net: add new packet dissector
test: add test for packet dissector
test-pmd: add more packet verbose decode options
app/test-pmd/cmdline_flow.c | 3 +- app/test-pmd/config.c | 33 +- app/test-pmd/testpmd.h | 11 + app/test-pmd/util.c | 77 +++- app/test/meson.build | 1 + app/test/test_dissect.c | 253 ++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- lib/net/meson.build | 2 + lib/net/rte_dissect.c | 416 ++++++++++++++++++++ lib/net/rte_dissect.h | 42 ++ lib/net/rte_icmp.h | 22 +- lib/net/version.map | 7 + 12 files changed, 850 insertions(+), 22 deletions(-) create mode 100644 app/test/test_dissect.c create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
Signature · 1 line
2.43.0
PATCH v6 1/4 net: add more icmp types
Add more defines for additional defined ICMP types.
--- lib/net/rte_icmp.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
lib/net/rte_icmp.h +18 -4
@@ -54,10 +54,24 @@ struct rte_icmp_hdr { } __rte_packed;/* ICMP packet types */ -#define RTE_IP_ICMP_ECHO_REPLY 0 -#define RTE_IP_ICMP_ECHO_REQUEST 8 -#define RTE_ICMP6_ECHO_REQUEST 128 -#define RTE_ICMP6_ECHO_REPLY 129 +#define RTE_IP_ICMP_ECHO_REPLY 0 +#define RTE_IP_ICMP_DEST_UNREACH 3 +#define RTE_IP_ICMP_SOURCE_QUENCH 4 +#define RTE_IP_ICMP_REDIRECT 5 +#define RTE_IP_ICMP_ECHO_REQUEST 8 +#define RTE_IP_ICMP_TIME_EXCEEDED 11 +#define RTE_IP_ICMP_PARAMETERPROB 12 +#define RTE_IP_ICMP_TIMESTAMP 13 +#define RTE_IP_ICMP_TIMESTAMPREPLY 14 +#define RTE_IP_ICMP_INFO_REQUEST 15 +#define RTE_IP_ICMP_INFO_REPLY 16 + +#define RTE_ICMP6_ECHO_REQUEST 128 +#define RTE_ICMP6_ECHO_REPLY 129 +#define RTE_ND_ROUTER_SOLICIT 133 +#define RTE_ND_ROUTER_ADVERT 134 +#define RTE_ND_NEIGHBOR_SOLICIT 135 +#define RTE_ND_NEIGHBOR_ADVERT 136 #ifdef __cplusplus }
Signature · 1 line
2.43.0
PATCH v6 2/4 net: add new packet dissector
In reply to Stephen HemmingerThe function rte_dissect_mbuf is used to decode the contents of an mbuf into ah uman readable format similar to what tshark uses.
For now, handles IP, IPv6, TCP, UDP, ICMP and ARP.
--- lib/net/meson.build | 2 + lib/net/rte_dissect.c | 416 ++++++++++++++++++++++++++++++++++++++++++ lib/net/rte_dissect.h | 42 +++++ lib/net/version.map | 7 + 4 files changed, 467 insertions(+) create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
lib/net/meson.build +2 -0
@@ -2,6 +2,7 @@ # Copyright(c) 2017-2020 Intel Corporation headers = files( + 'rte_dissect.h', 'rte_ip.h', 'rte_tcp.h', 'rte_udp.h',
@@ -30,6 +31,7 @@ headers = files( sources = files( 'rte_arp.c', + 'rte_dissect.c', 'rte_ether.c', 'rte_net.c', 'rte_net_crc.c',
lib/net/rte_dissect.c new file +416 -0
416 lines not on this page · raw message
lib/net/rte_dissect.h new file +42 -0
42 lines not on this page · raw message
lib/net/version.map +7 -0
@@ -12,3 +12,10 @@ DPDK_24 { local: *; }; + +EXPERIMENTAL { + global: + + # added in 24.11 + rte_dissect_mbuf; +};
Signature · 1 line
2.43.0
PATCH v6 3/4 test: add test for packet dissector
In reply to Stephen HemmingerAdd some tests for new packet dissector.
--- app/test/meson.build | 1 + app/test/test_dissect.c | 253 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 254 insertions(+) create mode 100644 app/test/test_dissect.c
app/test/meson.build +1 -0
@@ -62,6 +62,7 @@ source_file_deps = { 'test_debug.c': [], 'test_devargs.c': ['kvargs'], 'test_dispatcher.c': ['dispatcher'], + 'test_dissect.c': ['net'], 'test_distributor.c': ['distributor'], 'test_distributor_perf.c': ['distributor'], 'test_dmadev.c': ['dmadev', 'bus_vdev'],
app/test/test_dissect.c new file +253 -0
253 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v6 4/4 test-pmd: add more packet verbose decode options
In reply to Stephen HemmingerThe existing verbose levels 1..3 provide a messy multi-line output per packet. I found this unhelpful when diagnosing many types of problems like packet flow.
This patch keeps the previous levels and adds two new levels:
4: one line per packet is printed in a format resembling
tshark output. With addresses and protocol info.
5: dump packet in hex.
Useful if the driver is messing up the data.
--- app/test-pmd/cmdline_flow.c | 3 +- app/test-pmd/config.c | 33 ++++++--- app/test-pmd/testpmd.h | 11 +++ app/test-pmd/util.c | 77 +++++++++++++++++++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- 5 files changed, 111 insertions(+), 18 deletions(-)
app/test-pmd/cmdline_flow.c +2 -1
@@ -14143,7 +14143,8 @@ cmd_set_raw_parsed(const struct buffer *in) upper_layer = proto; } } -if (verbose_level &0x1 ) + +if (verbose_level >0 )printf ("total data size is %zu\n" , (*total_size));RTE_ASSERT ((*total_size) <=ACTION_RAW_ENCAP_MAX_DATA );memmove (data, (data_tail - (*total_size)), *total_size);
app/test-pmd/config.c +22 -11
@@ -6246,26 +6246,37 @@ configure_rxtx_dump_callbacks(uint16_t verbose)return ;#endif -RTE_ETH_FOREACH_DEV (portid) - { -if (verbose ==1 || verbose >2 ) +RTE_ETH_FOREACH_DEV (portid) { +switch (verbose) { +case VERBOSE_OFF : +remove_rx_dump_callbacks (portid); +remove_tx_dump_callbacks (portid); +break ; +case VERBOSE_RX :add_rx_dump_callbacks (portid); -else +remove_tx_dump_callbacks (portid); +break ; +case VERBOSE_TX : +add_tx_dump_callbacks (portid);remove_rx_dump_callbacks (portid); -if (verbose >=2 ) +break ; +default : +add_rx_dump_callbacks (portid);add_tx_dump_callbacks (portid); -else -remove_tx_dump_callbacks (portid); + } } }void set_verbose_level (uint16_t vb_level) { -printf ("Change verbose level from %u to %u\n" , - (unsigned int ) verbose_level, (unsigned int ) vb_level); - verbose_level = vb_level; -configure_rxtx_dump_callbacks (verbose_level); +if (vb_level <VERBOSE_MAX ) { +printf ("Change verbose level from %u to %u\n" , verbose_level, vb_level); + verbose_level = vb_level; +configure_rxtx_dump_callbacks (verbose_level); + }else { +fprintf (stderr,"Verbose level %u is out of range\n" , vb_level); + } }void
app/test-pmd/testpmd.h +11 -0
@@ -489,6 +489,17 @@ enum dcb_mode_enableextern uint8_t xstats_hide_zero;/**< Hide zero values for xstats display */ +enum verbose_mode { +VERBOSE_OFF =0 , +VERBOSE_RX , +VERBOSE_TX , +VERBOSE_BOTH , +VERBOSE_DISSECT , +VERBOSE_HEX , +VERBOSE_MAX +}; + +/* globals used for configuration */ extern uint8_t record_core_cycles;/**< Enables measurement of CPU cycles */ extern uint8_t record_burst_stats;/**< Enables display of RX and TX bursts */
app/test-pmd/util.c +72 -5
110 lines not on this page · raw message
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -1
@@ -677,7 +677,10 @@ Available levels are as following: * ``0`` silent except for error. * ``1`` fully verbose except for Tx packets. * ``2`` fully verbose except for Rx packets. -* ``> 2`` fully verbose. +* ``3`` fully verbose except for Tx and Rx packets. +* ``4`` dissected protocol information for Tx and Rx packets. +* ``5`` hex dump of packets + set log ~~~~~~~
Signature · 1 line
2.43.0
v7 cover Add network packet dissector
In reply to Stephen HemmingerWhile debugging TAP rte_flow discovered that test pmd verbose output was confusing and unhelpful. Instead, made a simple dissector that prints one line per packet like this in test-pmd with verbose level 4.
v7 - change rte_dissect to return number of characters that would
be printed (same as snprintf). And tests around that.
v6 - validate result of rte_dissect for simple packet
v5 - breakout the additional ICMP types into header
- fix some decoding bugs in ARP and ICMP
Stephen Hemminger (4):
net: add more icmp types
net: add new packet dissector
test: add test for packet dissector
test-pmd: add more packet verbose decode options
app/test-pmd/cmdline_flow.c | 3 +- app/test-pmd/config.c | 33 +- app/test-pmd/testpmd.h | 11 + app/test-pmd/util.c | 77 +++- app/test/meson.build | 1 + app/test/test_dissect.c | 302 ++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- lib/net/meson.build | 2 + lib/net/rte_dissect.c | 428 ++++++++++++++++++++ lib/net/rte_dissect.h | 45 ++ lib/net/rte_icmp.h | 22 +- lib/net/version.map | 7 + 12 files changed, 914 insertions(+), 22 deletions(-) create mode 100644 app/test/test_dissect.c create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
Signature · 1 line
2.43.0
PATCH v7 1/4 net: add more icmp types
Add more defines for additional defined ICMP types.
--- lib/net/rte_icmp.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
lib/net/rte_icmp.h +18 -4
@@ -54,10 +54,24 @@ struct rte_icmp_hdr { } __rte_packed;/* ICMP packet types */ -#define RTE_IP_ICMP_ECHO_REPLY 0 -#define RTE_IP_ICMP_ECHO_REQUEST 8 -#define RTE_ICMP6_ECHO_REQUEST 128 -#define RTE_ICMP6_ECHO_REPLY 129 +#define RTE_IP_ICMP_ECHO_REPLY 0 +#define RTE_IP_ICMP_DEST_UNREACH 3 +#define RTE_IP_ICMP_SOURCE_QUENCH 4 +#define RTE_IP_ICMP_REDIRECT 5 +#define RTE_IP_ICMP_ECHO_REQUEST 8 +#define RTE_IP_ICMP_TIME_EXCEEDED 11 +#define RTE_IP_ICMP_PARAMETERPROB 12 +#define RTE_IP_ICMP_TIMESTAMP 13 +#define RTE_IP_ICMP_TIMESTAMPREPLY 14 +#define RTE_IP_ICMP_INFO_REQUEST 15 +#define RTE_IP_ICMP_INFO_REPLY 16 + +#define RTE_ICMP6_ECHO_REQUEST 128 +#define RTE_ICMP6_ECHO_REPLY 129 +#define RTE_ND_ROUTER_SOLICIT 133 +#define RTE_ND_ROUTER_ADVERT 134 +#define RTE_ND_NEIGHBOR_SOLICIT 135 +#define RTE_ND_NEIGHBOR_ADVERT 136 #ifdef __cplusplus }
Signature · 1 line
2.43.0
PATCH v7 2/4 net: add new packet dissector
In reply to Stephen HemmingerThe function rte_dissect_mbuf is used to decode the contents of an mbuf into ah uman readable format similar to what tshark uses.
For now, handles IP, IPv6, TCP, UDP, ICMP and ARP.
--- lib/net/meson.build | 2 + lib/net/rte_dissect.c | 428 ++++++++++++++++++++++++++++++++++++++++++ lib/net/rte_dissect.h | 45 +++++ lib/net/version.map | 7 + 4 files changed, 482 insertions(+) create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
lib/net/meson.build +2 -0
@@ -2,6 +2,7 @@ # Copyright(c) 2017-2020 Intel Corporation headers = files( + 'rte_dissect.h', 'rte_ip.h', 'rte_tcp.h', 'rte_udp.h',
@@ -30,6 +31,7 @@ headers = files( sources = files( 'rte_arp.c', + 'rte_dissect.c', 'rte_ether.c', 'rte_net.c', 'rte_net_crc.c',
lib/net/rte_dissect.c new file +428 -0
428 lines not on this page · raw message
lib/net/rte_dissect.h new file +45 -0
45 lines not on this page · raw message
lib/net/version.map +7 -0
@@ -12,3 +12,10 @@ DPDK_24 { local: *; }; + +EXPERIMENTAL { + global: + + # added in 24.11 + rte_dissect_mbuf; +};
Signature · 1 line
2.43.0
PATCH v7 3/4 test: add test for packet dissector
In reply to Stephen HemmingerAdd some tests for new packet dissector.
--- app/test/meson.build | 1 + app/test/test_dissect.c | 302 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 303 insertions(+) create mode 100644 app/test/test_dissect.c
app/test/meson.build +1 -0
@@ -62,6 +62,7 @@ source_file_deps = { 'test_debug.c': [], 'test_devargs.c': ['kvargs'], 'test_dispatcher.c': ['dispatcher'], + 'test_dissect.c': ['net'], 'test_distributor.c': ['distributor'], 'test_distributor_perf.c': ['distributor'], 'test_dmadev.c': ['dmadev', 'bus_vdev'],
app/test/test_dissect.c new file +302 -0
302 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v7 4/4 test-pmd: add more packet verbose decode options
In reply to Stephen HemmingerThe existing verbose levels 1..3 provide a messy multi-line output per packet. I found this unhelpful when diagnosing many types of problems like packet flow.
This patch keeps the previous levels and adds two new levels:
4: one line per packet is printed in a format resembling
tshark output. With addresses and protocol info.
5: dump packet in hex.
Useful if the driver is messing up the data.
--- app/test-pmd/cmdline_flow.c | 3 +- app/test-pmd/config.c | 33 ++++++--- app/test-pmd/testpmd.h | 11 +++ app/test-pmd/util.c | 77 +++++++++++++++++++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- 5 files changed, 111 insertions(+), 18 deletions(-)
app/test-pmd/cmdline_flow.c +2 -1
@@ -14143,7 +14143,8 @@ cmd_set_raw_parsed(const struct buffer *in) upper_layer = proto; } } -if (verbose_level &0x1 ) + +if (verbose_level >0 )printf ("total data size is %zu\n" , (*total_size));RTE_ASSERT ((*total_size) <=ACTION_RAW_ENCAP_MAX_DATA );memmove (data, (data_tail - (*total_size)), *total_size);
app/test-pmd/config.c +22 -11
@@ -6246,26 +6246,37 @@ configure_rxtx_dump_callbacks(uint16_t verbose)return ;#endif -RTE_ETH_FOREACH_DEV (portid) - { -if (verbose ==1 || verbose >2 ) +RTE_ETH_FOREACH_DEV (portid) { +switch (verbose) { +case VERBOSE_OFF : +remove_rx_dump_callbacks (portid); +remove_tx_dump_callbacks (portid); +break ; +case VERBOSE_RX :add_rx_dump_callbacks (portid); -else +remove_tx_dump_callbacks (portid); +break ; +case VERBOSE_TX : +add_tx_dump_callbacks (portid);remove_rx_dump_callbacks (portid); -if (verbose >=2 ) +break ; +default : +add_rx_dump_callbacks (portid);add_tx_dump_callbacks (portid); -else -remove_tx_dump_callbacks (portid); + } } }void set_verbose_level (uint16_t vb_level) { -printf ("Change verbose level from %u to %u\n" , - (unsigned int ) verbose_level, (unsigned int ) vb_level); - verbose_level = vb_level; -configure_rxtx_dump_callbacks (verbose_level); +if (vb_level <VERBOSE_MAX ) { +printf ("Change verbose level from %u to %u\n" , verbose_level, vb_level); + verbose_level = vb_level; +configure_rxtx_dump_callbacks (verbose_level); + }else { +fprintf (stderr,"Verbose level %u is out of range\n" , vb_level); + } }void
app/test-pmd/testpmd.h +11 -0
@@ -489,6 +489,17 @@ enum dcb_mode_enableextern uint8_t xstats_hide_zero;/**< Hide zero values for xstats display */ +enum verbose_mode { +VERBOSE_OFF =0 , +VERBOSE_RX , +VERBOSE_TX , +VERBOSE_BOTH , +VERBOSE_DISSECT , +VERBOSE_HEX , +VERBOSE_MAX +}; + +/* globals used for configuration */ extern uint8_t record_core_cycles;/**< Enables measurement of CPU cycles */ extern uint8_t record_burst_stats;/**< Enables display of RX and TX bursts */
app/test-pmd/util.c +72 -5
110 lines not on this page · raw message
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -1
@@ -677,7 +677,10 @@ Available levels are as following: * ``0`` silent except for error. * ``1`` fully verbose except for Tx packets. * ``2`` fully verbose except for Rx packets. -* ``> 2`` fully verbose. +* ``3`` fully verbose except for Tx and Rx packets. +* ``4`` dissected protocol information for Tx and Rx packets. +* ``5`` hex dump of packets + set log ~~~~~~~
Signature · 1 line
2.43.0
Re: [PATCH v7 4/4] test-pmd: add more packet verbose decode options
Hi Stephen,
I have gone through your patch series and the hexdump option would be quite valuable for use in DTS.
However I am currently facing the issue of distinguishing noise packets from intentional packets within the verbose output. Prior to your patch, the intention was to use the Layer 4 port to distinguish between them, however with the hexdump option, the plan is to now use a custom payload.
The one issue is that with verbose level 5 does not print the required RSS hash and RSS queue information.
Would it be possible for you to add this to your patch series? Otherwise, do you have any ideas and/or solutions to tackle this specific problem?
On 8/2/24 20:56, Stephen Hemminger wrote:
<snip>
Quoted 10 lines
app/test-pmd/util.c +10
-0+static uint16_t +dump_pkt_burst (uint16_t port_id,uint16_t queue,struct rte_mbuf *pkts[], +uint16_t nb_pkts,int is_rx) +{ +if (unlikely (nb_pkts ==0 )) +return 0 ; + +switch (verbose_level) { + case VERBOSE_RX ... VERBOSE_BOTH: +dump_pkt_verbose (port_id, queue, pkts, nb_pkts, is_rx);
app/test-pmd/util.c dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], · line 367
Quoted 10 lines
app/test-pmd/util.c +10
-0+break ; +case VERBOSE_DISSECT : +dump_pkt_brief (port_id, queue, pkts, nb_pkts, is_rx); +break ; +case VERBOSE_HEX : +dump_pkt_hex (pkts, nb_pkts); + } +fflush (stdout); +return nb_pkts; +}
I have identified the function above that would require altering in order to accommodate the additional RSS information.
Thanks,
Alex
Re: [PATCH v7 4/4] test-pmd: add more packet verbose decode options
Quoted 5 lines · On Tue, 20 Aug 2024 14:42:56 +0100 Alex Chapman <[email protected]> wrote:
Hi Stephen,
I have gone through your patch series and the hexdump option would be quite valuable for use in DTS.
Quoted 7 lines
However I am currently facing the issue of distinguishing noise packets from intentional packets within the verbose output. Prior to your patch, the intention was to use the Layer 4 port to distinguish between them, however with the hexdump option, the plan is to now use a custom payload.
The one issue is that with verbose level 5 does not print the required RSS hash and RSS queue information.
The queue is there, in the output. Not sure if the hash matters. I wanted to keep to tshark format as much as possible.
For DTS, maybe having a yet another JSON verbose format would be best. Something with mbuf bits in JSON.
Re: [PATCH v7 4/4] test-pmd: add more packet verbose decode options
Quoted 13 lines · Stephen Hemminger
Quoted 10 lines · On Tue, 20 Aug 2024 14:42:56 +0100 Alex Chapman <[email protected]> wrote:
Hi Stephen,
I have gone through your patch series and the hexdump option would be quite valuable for use in DTS.
However I am currently facing the issue of distinguishing noise packets from intentional packets within the verbose output. Prior to your patch, the intention was to use the Layer 4 port to distinguish between them, however with the hexdump option, the plan is to now use a custom payload.
Quoted 6 lines
Quoted 2 lines
The one issue is that with verbose level 5 does not print the required RSS hash and RSS queue information.
The queue is there, in the output. Not sure if the hash matters. I wanted to keep to tshark format as much as possible.
We appreciate that but the RSS info is valuable to us. Seeing as different enum values offer different info rather than different levels, maybe we could change the enum to flags
+enum verbose_mode {
+ VERBOSE_OFF = 0,
+ VERBOSE_RX = 0x1,
+ VERBOSE_TX = 0x2,
+ VERBOSE_BOTH = 0x4,
+ VERBOSE_DISSECT = 0x8,
+ VERBOSE_HEX = 0x10
+};
Then the flags can be ORed together:
verbose_flags = VERBOSE_RX | VERBOSE_TX | VERBOSE_HEX | VERBOSE_RSS
And then instead of switch each print is an if that checks for flag being set in the verbose_flags. This way you only get the RSS if you request it.
Re: [PATCH v7 4/4] test-pmd: add more packet verbose decode options
Quoted 17 lines · On Thu, 22 Aug 2024 10:04:55 +0100 Paul Szczepanek <[email protected]>…
Quoted 16 lines · Stephen Hemminger
Quoted 12 lines · On Tue, 20 Aug 2024 14:42:56 +0100 Alex Chapman <[email protected]> wrote:
Hi Stephen,
I have gone through your patch series and the hexdump option would be quite valuable for use in DTS.
However I am currently facing the issue of distinguishing noise packets from intentional packets within the verbose output. Prior to your patch, the intention was to use the Layer 4 port to distinguish between them, however with the hexdump option, the plan is to now use a custom payload.
The one issue is that with verbose level 5 does not print the required RSS hash and RSS queue information.
Quoted 7 lines
Quoted 3 lines
The queue is there, in the output. Not sure if the hash matters. I wanted to keep to tshark format as much as possible.
We appreciate that but the RSS info is valuable to us. Seeing as different enum values offer different info rather than different levels, maybe we could change the enum to flags
See new patch series, it also has JSON output.
v8 cover Test-pmd packet decode enhancements
In reply to Stephen HemmingerWhile debugging TAP rte_flow discovered that test pmd verbose output was confusing and unhelpful. Instead, made a simple dissector that prints one line per packet like this in test-pmd.
The new commands are:
testpmd> set output /tmp/packet.log
testpmd> set format dissect
To enable packet logging need to use:
testpmd> set verbose 3
v8 - added JSON output format, and ability to redirect packet log,
and don't overload verbose option.
v7 - change rte_dissect to return number of characters that would
be printed (same as snprintf). And tests around that.
v6 - validate result of rte_dissect for simple packet
v5 - breakout the additional ICMP types into header
- fix some decoding bugs in ARP and ICMP
Stephen Hemminger (7):
net: add more icmp types
net: add new packet dissector
test: add test for packet dissector
test-pmd: add option to redirect packet log
test-pmd: add hex decode
test-pmd: add packet dissect format
test-pmd: add a JSON packet output
app/test-pmd/cmdline.c | 81 ++++ app/test-pmd/config.c | 47 +++ app/test-pmd/testpmd.c | 4 + app/test-pmd/testpmd.h | 12 + app/test-pmd/util.c | 225 +++++++++- app/test/meson.build | 1 + app/test/test_dissect.c | 302 ++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 22 + lib/net/meson.build | 2 + lib/net/rte_dissect.c | 428 ++++++++++++++++++++ lib/net/rte_dissect.h | 45 ++ lib/net/rte_icmp.h | 22 +- lib/net/version.map | 7 + 13 files changed, 1187 insertions(+), 11 deletions(-) create mode 100644 app/test/test_dissect.c create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
Signature · 1 line
2.45.2
PATCH v8 1/7 net: add more icmp types
Add more defines for additional defined ICMP types.
--- lib/net/rte_icmp.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
lib/net/rte_icmp.h +18 -4
@@ -54,10 +54,24 @@ struct rte_icmp_hdr { } __rte_packed;/* ICMP packet types */ -#define RTE_IP_ICMP_ECHO_REPLY 0 -#define RTE_IP_ICMP_ECHO_REQUEST 8 -#define RTE_ICMP6_ECHO_REQUEST 128 -#define RTE_ICMP6_ECHO_REPLY 129 +#define RTE_IP_ICMP_ECHO_REPLY 0 +#define RTE_IP_ICMP_DEST_UNREACH 3 +#define RTE_IP_ICMP_SOURCE_QUENCH 4 +#define RTE_IP_ICMP_REDIRECT 5 +#define RTE_IP_ICMP_ECHO_REQUEST 8 +#define RTE_IP_ICMP_TIME_EXCEEDED 11 +#define RTE_IP_ICMP_PARAMETERPROB 12 +#define RTE_IP_ICMP_TIMESTAMP 13 +#define RTE_IP_ICMP_TIMESTAMPREPLY 14 +#define RTE_IP_ICMP_INFO_REQUEST 15 +#define RTE_IP_ICMP_INFO_REPLY 16 + +#define RTE_ICMP6_ECHO_REQUEST 128 +#define RTE_ICMP6_ECHO_REPLY 129 +#define RTE_ND_ROUTER_SOLICIT 133 +#define RTE_ND_ROUTER_ADVERT 134 +#define RTE_ND_NEIGHBOR_SOLICIT 135 +#define RTE_ND_NEIGHBOR_ADVERT 136 #ifdef __cplusplus }
Signature · 1 line
2.45.2
PATCH v8 2/7 net: add new packet dissector
In reply to Stephen HemmingerThe function rte_dissect_mbuf is used to decode the contents of an mbuf into ah uman readable format similar to what tshark uses.
For now, handles IP, IPv6, TCP, UDP, ICMP and ARP.
--- lib/net/meson.build | 2 + lib/net/rte_dissect.c | 428 ++++++++++++++++++++++++++++++++++++++++++ lib/net/rte_dissect.h | 45 +++++ lib/net/version.map | 7 + 4 files changed, 482 insertions(+) create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
lib/net/meson.build +2 -0
@@ -2,6 +2,7 @@ # Copyright(c) 2017-2020 Intel Corporation headers = files( + 'rte_dissect.h', 'rte_ip.h', 'rte_tcp.h', 'rte_udp.h',
@@ -30,6 +31,7 @@ headers = files( sources = files( 'rte_arp.c', + 'rte_dissect.c', 'rte_ether.c', 'rte_net.c', 'rte_net_crc.c',
lib/net/rte_dissect.c new file +428 -0
428 lines not on this page · raw message
lib/net/rte_dissect.h new file +45 -0
45 lines not on this page · raw message
lib/net/version.map +7 -0
@@ -12,3 +12,10 @@ DPDK_25 { local: *; }; + +EXPERIMENTAL { + global: + + # added in 24.11 + rte_dissect_mbuf; +};
Signature · 1 line
2.45.2
PATCH v8 3/7 test: add test for packet dissector
In reply to Stephen HemmingerAdd some tests for new packet dissector.
--- app/test/meson.build | 1 + app/test/test_dissect.c | 302 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 303 insertions(+) create mode 100644 app/test/test_dissect.c
app/test/meson.build +1 -0
@@ -62,6 +62,7 @@ source_file_deps = { 'test_debug.c': [], 'test_devargs.c': ['kvargs'], 'test_dispatcher.c': ['dispatcher'], + 'test_dissect.c': ['net'], 'test_distributor.c': ['distributor'], 'test_distributor_perf.c': ['distributor'], 'test_dmadev.c': ['dmadev', 'bus_vdev'],
app/test/test_dissect.c new file +302 -0
302 lines not on this page · raw message
Signature · 1 line
2.45.2
PATCH v8 4/7 test-pmd: add option to redirect packet log
In reply to Stephen HemmingerWhen running tests in interactive mode, it is useful to be able to redirect the packet decode (verbose output) into a file.
--- app/test-pmd/cmdline.c | 41 +++++++++++++++++++++ app/test-pmd/config.c | 23 ++++++++++++ app/test-pmd/testpmd.c | 3 ++ app/test-pmd/testpmd.h | 3 ++ app/test-pmd/util.c | 11 +++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 ++++ 6 files changed, 86 insertions(+), 2 deletions(-)
app/test-pmd/cmdline.c +41 -0
@@ -302,6 +302,9 @@ static void cmd_help_long_parsed(void *parsed_result,"set verbose (level)\n" " Set the debug verbosity level X.\n\n" +"set output (filename)\n" +" Set the packet debug log file\n\n" +"set log global|(type) (level)\n" " Set the log level.\n\n"
@@ -3853,6 +3856,43 @@ static cmdline_parse_inst_t cmd_set_numbers = { }, }; + +/* *** SET OUTPUT FILENAME *** */ +struct cmd_set_output_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t output; +cmdline_fixed_string_t filename; +}; + +static void +cmd_set_output_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_output_result *res = parsed_result; + +set_output_file (res->filename); +} + +static cmdline_parse_token_string_t cmd_set_output_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_output_result, set, "set"); +static cmdline_parse_token_string_t cmd_set_output_output = + TOKEN_STRING_INITIALIZER(struct cmd_set_output_result, output, "output"); +static cmdline_parse_token_string_t cmd_set_output_name = + TOKEN_STRING_INITIALIZER(struct cmd_set_output_result, filename, NULL); + +static cmdline_parse_inst_t cmd_set_output = { + .f = cmd_set_output_parsed, + .data =NULL , + .help_str ="set output <filename>" , + .tokens = { + (void *)&cmd_set_output_set, + (void *)&cmd_set_output_output, + (void *)&cmd_set_output_name, +NULL , + }, +}; +/* *** SET LOG LEVEL CONFIGURATION *** */ struct cmd_set_log_result {
@@ -13166,6 +13206,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_reset, (cmdline_parse_inst_t *)&cmd_set_numbers, (cmdline_parse_inst_t *)&cmd_set_log, + (cmdline_parse_inst_t *)&cmd_set_output, (cmdline_parse_inst_t *)&cmd_set_rxoffs, (cmdline_parse_inst_t *)&cmd_set_rxpkts, (cmdline_parse_inst_t *)&cmd_set_rxhdrs,
app/test-pmd/config.c +23 -0
@@ -6268,6 +6268,29 @@ set_verbose_level(uint16_t vb_level)configure_rxtx_dump_callbacks (verbose_level); } +void +set_output_file (const char *filename) +{ +FILE *outf, *oldf; + +if (!strcmp (filename,"-" )) { + outf = stdout; + }else { + outf =fopen (filename,"a" ); +if (outf ==NULL ) { +perror (filename); +return ; + } + } + + oldf =rte_atomic_exchange_explicit (&output_file, outf, rte_memory_order_seq_cst); +if (oldf !=NULL && oldf != stdout) { +/* make sure other threads are not mid print */ +rte_delay_us_sleep (US_PER_S /10 ); +fclose (oldf); + } +} +void vlan_extend_set (portid_t port_id,int on) {
app/test-pmd/testpmd.c +3 -0
@@ -99,6 +99,7 @@#define EXTBUF_ZONE_SIZE (RTE_PGSIZE_2M - 4 * RTE_CACHE_LINE_SIZE)uint16_t verbose_level =0 ;/**< Silent by default. */ +RTE_ATOMIC (FILE *) output_file;/**< log to console by default. */ int testpmd_logtype;/**< Log type for testpmd logs */ /* use main core for command line ? */
@@ -4543,6 +4544,8 @@ main(int argc, char** argv)rte_exit (EXIT_FAILURE ,"Cannot register log type" );rte_log_set_level (testpmd_logtype,RTE_LOG_DEBUG ); + output_file = stdout; + diag =rte_eal_init (argc, argv);if (diag <0 ) rte_exit(EXIT_FAILURE, "Cannot init EAL: %s\n",
app/test-pmd/testpmd.h +3 -0
@@ -17,6 +17,7 @@#include <rte_ethdev.h> #include <rte_flow.h> #include <rte_mbuf_dyn.h> +#include <rte_stdatomic.h> #include <cmdline.h> #include <cmdline_parse.h>
@@ -493,6 +494,7 @@ extern uint8_t xstats_hide_zero; /**< Hide zero values for xstats display */extern uint8_t record_core_cycles;/**< Enables measurement of CPU cycles */ extern uint8_t record_burst_stats;/**< Enables display of RX and TX bursts */ extern uint16_t verbose_level;/**< Drives messages being displayed, if any. */ +extern RTE_ATOMIC (FILE *) output_file;/**< Where packet data is written */ extern int testpmd_logtype;/**< Log type for testpmd logs */ extern uint8_t interactive;extern uint8_t auto_start;
@@ -1102,6 +1104,7 @@ void set_xstats_hide_zero(uint8_t on_off);void set_record_core_cycles (uint8_t on_off);void set_record_burst_stats (uint8_t on_off);void set_verbose_level (uint16_t vb_level); +void set_output_file (const char *filename);void set_rx_pkt_segments (unsigned int *seg_lengths,unsigned int nb_segs);void set_rx_pkt_hdrs (unsigned int *seg_protos,unsigned int nb_segs);void show_rx_pkt_hdrs (void );
app/test-pmd/util.c +9 -2
@@ -89,9 +89,15 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],size_t buf_size =MAX_STRING_LEN ;size_t cur_len =0 ;uint64_t restore_info_dynflag; +FILE *outf;if (!nb_pkts)return ; + + outf =rte_atomic_load_explicit (&output_file, rte_memory_order_relaxed); +if (!outf) +return ; + restore_info_dynflag =rte_flow_restore_info_dynflag (); MKDUMPSTR(print_buf, buf_size, cur_len, "port %u/queue %u: %s %u packets\n", port_id, queue,
@@ -292,11 +298,12 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],MKDUMPSTR (print_buf, buf_size, cur_len,"INVALID mbuf: %s\n" , reason);if (cur_len >= buf_size) -printf ("%s ...\n" , print_buf); +fprintf (outf,"%s ...\n" , print_buf);else -printf ("%s" , print_buf); +fprintf (outf,"%s" , print_buf); cur_len =0 ; } +fflush (outf); }uint16_t
doc/guides/testpmd_app_ug/testpmd_funcs.rst +7 -0
@@ -665,6 +665,13 @@ Reset forwarding to the default configuration:: testpmd> set default +set output +~~~~~~~~~~ + +Redirect the debug log:: + + testpmd> set output /tmp/packet.log + set verbose ~~~~~~~~~~~
Signature · 1 line
2.45.2
PATCH v8 5/7 test-pmd: add hex decode
In reply to Stephen HemmingerThis adds new command:
testpmd> set format hex
which decodes packet in hex.
--- app/test-pmd/cmdline.c | 40 +++++++++++++++++ app/test-pmd/config.c | 11 +++++ app/test-pmd/testpmd.c | 1 + app/test-pmd/testpmd.h | 7 +++ app/test-pmd/util.c | 48 ++++++++++++++++----- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 13 ++++++ 6 files changed, 109 insertions(+), 11 deletions(-)
app/test-pmd/cmdline.c +40 -0
@@ -305,6 +305,9 @@ static void cmd_help_long_parsed(void *parsed_result,"set output (filename)\n" " Set the packet debug log file\n\n" +"set format (verbose|hex)\n" +" Set the format of packet log\\n" +"set log global|(type) (level)\n" " Set the log level.\n\n"
@@ -3893,6 +3896,42 @@ static cmdline_parse_inst_t cmd_set_output = { }, }; +/* *** SET FORMAT OF PACKET LOG */ +struct cmd_set_format_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t format; +cmdline_fixed_string_t value; +}; + +static void +cmd_set_format_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_format_result *res = parsed_result; + +set_output_format (res->value); +} + +static cmdline_parse_token_string_t cmd_set_format_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, set, "set"); +static cmdline_parse_token_string_t cmd_set_format_output = + TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, format, "format"); +static cmdline_parse_token_string_t cmd_set_format_value = + TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "verbose#hex"); + +static cmdline_parse_inst_t cmd_set_format = { + .f = cmd_set_format_parsed, + .data =NULL , + .help_str ="set format verbose|hex" , + .tokens = { + (void *)&cmd_set_format_set, + (void *)&cmd_set_format_output, + (void *)&cmd_set_format_value, +NULL , + }, +}; +/* *** SET LOG LEVEL CONFIGURATION *** */ struct cmd_set_log_result {
@@ -13207,6 +13246,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_numbers, (cmdline_parse_inst_t *)&cmd_set_log, (cmdline_parse_inst_t *)&cmd_set_output, + (cmdline_parse_inst_t *)&cmd_set_format, (cmdline_parse_inst_t *)&cmd_set_rxoffs, (cmdline_parse_inst_t *)&cmd_set_rxpkts, (cmdline_parse_inst_t *)&cmd_set_rxhdrs,
app/test-pmd/config.c +11 -0
@@ -6268,6 +6268,17 @@ set_verbose_level(uint16_t vb_level)configure_rxtx_dump_callbacks (verbose_level); } +void +set_output_format (const char *mode) +{ +if (!strcmp (mode,"verbose" )) + output_format =OUTPUT_MODE_VERBOSE ; +else if (!strcmp (mode,"hex" )) + output_format =OUTPUT_MODE_HEX ; +else +fprintf (stderr,"Unknown output format '%s'\n" , mode); +} +void set_output_file (const char *filename) {
app/test-pmd/testpmd.c +1 -0
@@ -100,6 +100,7 @@uint16_t verbose_level =0 ;/**< Silent by default. */ RTE_ATOMIC (FILE *) output_file;/**< log to console by default. */ +enum output_mode output_format;/**< default to original mode. */ int testpmd_logtype;/**< Log type for testpmd logs */ /* use main core for command line ? */
app/test-pmd/testpmd.h +7 -0
@@ -488,6 +488,11 @@ enum dcb_mode_enable DCB_ENABLED }; +enum output_mode { +OUTPUT_MODE_VERBOSE =0 , +OUTPUT_MODE_HEX , +}; +extern uint8_t xstats_hide_zero;/**< Hide zero values for xstats display */ /* globals used for configuration */
@@ -495,6 +500,7 @@ extern uint8_t record_core_cycles; /**< Enables measurement of CPU cycles */extern uint8_t record_burst_stats;/**< Enables display of RX and TX bursts */ extern uint16_t verbose_level;/**< Drives messages being displayed, if any. */ extern RTE_ATOMIC (FILE *) output_file;/**< Where packet data is written */ +extern enum output_mode output_format;/**< Format of packet decode */ extern int testpmd_logtype;/**< Log type for testpmd logs */ extern uint8_t interactive;extern uint8_t auto_start;
@@ -1104,6 +1110,7 @@ void set_xstats_hide_zero(uint8_t on_off);void set_record_core_cycles (uint8_t on_off);void set_record_burst_stats (uint8_t on_off);void set_verbose_level (uint16_t vb_level); +void set_output_format (const char *mode);void set_output_file (const char *filename);void set_rx_pkt_segments (unsigned int *seg_lengths,unsigned int nb_segs);void set_rx_pkt_hdrs (unsigned int *seg_protos,unsigned int nb_segs);
app/test-pmd/util.c +37 -11
72 lines not on this page · raw message
doc/guides/testpmd_app_ug/testpmd_funcs.rst +13 -0
@@ -672,6 +672,19 @@ Redirect the debug log:: testpmd> set output /tmp/packet.log +set format +~~~~~~~~~~ + +Chose the output format for packet debug log:: + + testpmd> set format verbose|hex + +Available formats are: + +* ``verbose`` print the packet meta data information +* ``hex`` print the mbuf flags and data in hex + + set verbose ~~~~~~~~~~~
Signature · 1 line
2.45.2
PATCH v8 6/7 test-pmd: add packet dissect format
In reply to Stephen HemmingerAdd ability to get decode packet in summary tshark style format.
--- app/test-pmd/cmdline.c | 6 ++-- app/test-pmd/config.c | 22 +++++++++---- app/test-pmd/testpmd.h | 1 + app/test-pmd/util.c | 36 +++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 3 +- 5 files changed, 58 insertions(+), 10 deletions(-)
app/test-pmd/cmdline.c +3 -3
@@ -305,7 +305,7 @@ static void cmd_help_long_parsed(void *parsed_result,"set output (filename)\n" " Set the packet debug log file\n\n" -"set format (verbose|hex)\n" +"set format (dissect|hex|verbose)\n" " Set the format of packet log\\n" "set log global|(type) (level)\n"
@@ -3918,12 +3918,12 @@ static cmdline_parse_token_string_t cmd_set_format_set =static cmdline_parse_token_string_t cmd_set_format_output = TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, format, "format");static cmdline_parse_token_string_t cmd_set_format_value = - TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "verbose#hex"); + TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "dissect#hex#verbose");static cmdline_parse_inst_t cmd_set_format = { .f = cmd_set_format_parsed, .data =NULL , - .help_str ="set format verbose|hex" , + .help_str ="set format dissect|hex|verbose" , .tokens = { (void *)&cmd_set_format_set, (void *)&cmd_set_format_output,
app/test-pmd/config.c +16 -6
@@ -6271,12 +6271,22 @@ set_verbose_level(uint16_t vb_level)void set_output_format (const char *mode) { -if (!strcmp (mode,"verbose" )) - output_format =OUTPUT_MODE_VERBOSE ; -else if (!strcmp (mode,"hex" )) - output_format =OUTPUT_MODE_HEX ; -else -fprintf (stderr,"Unknown output format '%s'\n" , mode); +static const char *formats[] = { + [OUTPUT_MODE_VERBOSE ] ="verbose" , + [OUTPUT_MODE_HEX ] ="hex" , + [OUTPUT_MODE_DISSECT ] ="dissect" , + }; + +printf ("Change output format from %s to %s\n" , formats[output_format], mode); + +for (unsigned int i =0 ; i <RTE_DIM (formats); i++) { +if (strcasecmp (mode, formats[i]) ==0 ) { + output_format = i; +return ; + } + } + +fprintf (stderr,"Unknown output format '%s'\n" , mode); }void
app/test-pmd/testpmd.h +1 -0
@@ -491,6 +491,7 @@ enum dcb_mode_enableenum output_mode {OUTPUT_MODE_VERBOSE =0 ,OUTPUT_MODE_HEX , +OUTPUT_MODE_DISSECT , };extern uint8_t xstats_hide_zero;/**< Hide zero values for xstats display */
app/test-pmd/util.c +36 -0
@@ -8,6 +8,7 @@#include <rte_bitops.h> #include <rte_net.h> #include <rte_mbuf.h> +#include <rte_dissect.h> #include <rte_ether.h> #include <rte_vxlan.h> #include <rte_ethdev.h>
@@ -305,6 +306,38 @@ dump_pkt_hex(FILE *outf, struct rte_mbuf *pkts[], uint16_t nb_pkts)rte_pktmbuf_dump (outf, pkts[i],MAX_DUMP_LEN ); } +/* Brief tshark style one line output which is +* number time_delta Source Destination Protocol len info +*/ +static void +dump_pkt_brief (FILE *outf,uint16_t port,uint16_t queue, +struct rte_mbuf *pkts[],uint16_t nb_pkts,int is_rx) +{ +static uint64_t start_cycles; +static RTE_ATOMIC (uint64_t ) packet_count =1 ; +uint64_t now, count; +double interval; + +/* Compute time interval from the first packet received */ + now =rte_rdtsc (); +if (start_cycles ==0 ) { + start_cycles = now; +printf ("Seq# Time Port:Que R Description\n" ); + } + interval = (double )(now - start_cycles) / (double )rte_get_tsc_hz (); + +/* Packet counter needs to be thread safe */ + count =rte_atomic_fetch_add_explicit (&packet_count, nb_pkts, rte_memory_order_relaxed); + +for (uint16_t i =0 ; i < nb_pkts; i++) { +const struct rte_mbuf *mb = pkts[i]; +char str[256 ]; + +rte_dissect_mbuf (str,sizeof (str), mb,0 ); +fprintf (outf,"%6" PRIu64" %11.9f %4u:%-3u %c %s\n" , + count + i, interval, port, queue, is_rx ?'R' :'T' , str); + } +} static void dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
@@ -326,6 +359,9 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],case OUTPUT_MODE_HEX :dump_pkt_hex (outf, pkts, nb_pkts);break ; +case OUTPUT_MODE_DISSECT : +dump_pkt_brief (outf, port_id, queue, pkts, nb_pkts, is_rx); +break ;default :return ; }
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -1
@@ -677,12 +677,13 @@ set format Chose the output format for packet debug log:: - testpmd> set format verbose|hex + testpmd> set format dissect|hex|verbose Available formats are: * ``verbose`` print the packet meta data information * ``hex`` print the mbuf flags and data in hex +* ``dissect`` print the packet in tshark summary format set verbose
Signature · 1 line
2.45.2
PATCH v8 7/7 test-pmd: add a JSON packet output
In reply to Stephen HemmingerWhen doing automated testing it is useful to show packet meta data in JSON.
--- app/test-pmd/cmdline.c | 6 +- app/test-pmd/config.c | 3 + app/test-pmd/testpmd.h | 1 + app/test-pmd/util.c | 142 ++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +- 5 files changed, 153 insertions(+), 6 deletions(-)
app/test-pmd/cmdline.c +3 -3
@@ -305,7 +305,7 @@ static void cmd_help_long_parsed(void *parsed_result,"set output (filename)\n" " Set the packet debug log file\n\n" -"set format (dissect|hex|verbose)\n" +"set format (dissect|hex|json|verbose)\n" " Set the format of packet log\\n" "set log global|(type) (level)\n"
@@ -3918,12 +3918,12 @@ static cmdline_parse_token_string_t cmd_set_format_set =static cmdline_parse_token_string_t cmd_set_format_output = TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, format, "format");static cmdline_parse_token_string_t cmd_set_format_value = - TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "dissect#hex#verbose"); + TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "dissect#hex#json@verbose");static cmdline_parse_inst_t cmd_set_format = { .f = cmd_set_format_parsed, .data =NULL , - .help_str ="set format dissect|hex|verbose" , + .help_str ="set format dissect|hex|json|verbose" , .tokens = { (void *)&cmd_set_format_set, (void *)&cmd_set_format_output,
app/test-pmd/config.c +3 -0
@@ -6275,6 +6275,9 @@ set_output_format(const char *mode) [OUTPUT_MODE_VERBOSE] = "verbose", [OUTPUT_MODE_HEX] = "hex", [OUTPUT_MODE_DISSECT ] ="dissect" , +#ifdef RTE_HAS_JANSSON + [OUTPUT_MODE_JSON ] ="json" , +#endif };printf ("Change output format from %s to %s\n" , formats[output_format], mode);
app/test-pmd/testpmd.h +1 -0
@@ -492,6 +492,7 @@ enum output_mode {OUTPUT_MODE_VERBOSE =0 ,OUTPUT_MODE_HEX ,OUTPUT_MODE_DISSECT , + OUTPUT_MODE_JSON, };extern uint8_t xstats_hide_zero;/**< Hide zero values for xstats display */
app/test-pmd/util.c +142 -0
154 lines not on this page · raw message
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -3
@@ -677,13 +677,14 @@ set format Chose the output format for packet debug log:: - testpmd> set format dissect|hex|verbose + testpmd> set format dissect|hex|json|verbose Available formats are: -* ``verbose`` print the packet meta data information -* ``hex`` print the mbuf flags and data in hex * ``dissect`` print the packet in tshark summary format +* ``hex`` print the mbuf flags and data in hex +* ``json`` print the packet meta data in json +* ``verbose`` print the packet meta data information set verbose
Signature · 1 line
2.45.2
v9 cover test-pmd packet decoding enhancements
In reply to Stephen HemmingerWhile debugging TAP rte_flow discovered that test pmd verbose output was confusing and unhelpful. Instead, made a simple dissector that prints one line per packet like this in test-pmd.
The new commands are:
testpmd> set output /tmp/packet.log
testpmd> set format dissect
To enable packet logging need to use:
testpmd> set verbose 3
v9 - some fixes to JSON format
extend hex to print hash and port
v8 - added JSON output format, and ability to redirect packet log,
and don't overload verbose option.
Stephen Hemminger (8):
net: add more icmp types
net: add new packet dissector
mbuf: decode the hash and fdir info in rte_pktmbuf_dump
test: add test for packet dissector
test-pmd: add option to redirect packet log
test-pmd: add hex decode
test-pmd: add packet dissect format
test-pmd: add a JSON packet output
app/test-pmd/cmdline.c | 81 ++++ app/test-pmd/config.c | 48 +++ app/test-pmd/testpmd.c | 4 + app/test-pmd/testpmd.h | 12 + app/test-pmd/util.c | 256 +++++++++++- app/test/meson.build | 1 + app/test/test_dissect.c | 302 ++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 22 + lib/mbuf/rte_mbuf.c | 14 + lib/net/meson.build | 2 + lib/net/rte_dissect.c | 428 ++++++++++++++++++++ lib/net/rte_dissect.h | 45 ++ lib/net/rte_icmp.h | 22 +- lib/net/version.map | 7 + 14 files changed, 1233 insertions(+), 11 deletions(-) create mode 100644 app/test/test_dissect.c create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
Signature · 1 line
2.45.2
PATCH v9 1/8 net: add more icmp types
Add more defines for additional defined ICMP types.
--- lib/net/rte_icmp.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
lib/net/rte_icmp.h +18 -4
@@ -54,10 +54,24 @@ struct rte_icmp_hdr { } __rte_packed;/* ICMP packet types */ -#define RTE_IP_ICMP_ECHO_REPLY 0 -#define RTE_IP_ICMP_ECHO_REQUEST 8 -#define RTE_ICMP6_ECHO_REQUEST 128 -#define RTE_ICMP6_ECHO_REPLY 129 +#define RTE_IP_ICMP_ECHO_REPLY 0 +#define RTE_IP_ICMP_DEST_UNREACH 3 +#define RTE_IP_ICMP_SOURCE_QUENCH 4 +#define RTE_IP_ICMP_REDIRECT 5 +#define RTE_IP_ICMP_ECHO_REQUEST 8 +#define RTE_IP_ICMP_TIME_EXCEEDED 11 +#define RTE_IP_ICMP_PARAMETERPROB 12 +#define RTE_IP_ICMP_TIMESTAMP 13 +#define RTE_IP_ICMP_TIMESTAMPREPLY 14 +#define RTE_IP_ICMP_INFO_REQUEST 15 +#define RTE_IP_ICMP_INFO_REPLY 16 + +#define RTE_ICMP6_ECHO_REQUEST 128 +#define RTE_ICMP6_ECHO_REPLY 129 +#define RTE_ND_ROUTER_SOLICIT 133 +#define RTE_ND_ROUTER_ADVERT 134 +#define RTE_ND_NEIGHBOR_SOLICIT 135 +#define RTE_ND_NEIGHBOR_ADVERT 136 #ifdef __cplusplus }
Signature · 1 line
2.45.2
PATCH v9 2/8 net: add new packet dissector
In reply to Stephen HemmingerThe function rte_dissect_mbuf is used to decode the contents of an mbuf into ah uman readable format similar to what tshark uses.
For now, handles IP, IPv6, TCP, UDP, ICMP and ARP.
--- lib/net/meson.build | 2 + lib/net/rte_dissect.c | 428 ++++++++++++++++++++++++++++++++++++++++++ lib/net/rte_dissect.h | 45 +++++ lib/net/version.map | 7 + 4 files changed, 482 insertions(+) create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
lib/net/meson.build +2 -0
@@ -2,6 +2,7 @@ # Copyright(c) 2017-2020 Intel Corporation headers = files( + 'rte_dissect.h', 'rte_ip.h', 'rte_tcp.h', 'rte_udp.h',
@@ -30,6 +31,7 @@ headers = files( sources = files( 'rte_arp.c', + 'rte_dissect.c', 'rte_ether.c', 'rte_net.c', 'rte_net_crc.c',
lib/net/rte_dissect.c new file +428 -0
428 lines not on this page · raw message
lib/net/rte_dissect.h new file +45 -0
45 lines not on this page · raw message
lib/net/version.map +7 -0
@@ -12,3 +12,10 @@ DPDK_25 { local: *; }; + +EXPERIMENTAL { + global: + + # added in 24.11 + rte_dissect_mbuf; +};
Signature · 1 line
2.45.2
PATCH v9 3/8 mbuf: decode the hash and fdir info in rte_pktmbuf_dump
In reply to Stephen HemmingerUseful to be able to see the meta data in the hex dump.
--- lib/mbuf/rte_mbuf.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
lib/mbuf/rte_mbuf.c +14 -0
@@ -678,12 +678,26 @@ rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len)fprintf (f," pkt_len=%u, ol_flags=%#" PRIx64", nb_segs=%u, port=%u" , m->pkt_len, m->ol_flags, m->nb_segs, m->port); +if (m->port !=RTE_MBUF_PORT_INVALID ) +fprintf (f,", port=%u" , m->port); +if (m->ol_flags & (RTE_MBUF_F_RX_QINQ |RTE_MBUF_F_TX_QINQ ))fprintf (f,", vlan_tci_outer=%u" , m->vlan_tci_outer);if (m->ol_flags & (RTE_MBUF_F_RX_VLAN |RTE_MBUF_F_TX_VLAN ))fprintf (f,", vlan_tci=%u" , m->vlan_tci); +if (m->ol_flags &RTE_MBUF_F_RX_RSS_HASH ) +fprintf (f,", rss=%#x" , m->hash.rss); +else if (m->ol_flags &RTE_MBUF_F_RX_FDIR ) { +if (m->ol_flags &RTE_MBUF_F_RX_FDIR_ID ) +fprintf (f,", fdir id=%u" , m->hash.fdir.id); +else if (m->ol_flags &RTE_MBUF_F_RX_FDIR_FLX ) +fprintf (f,", fdir flex=%#x %x" , m->hash.fdir.hi, m->hash.fdir.lo); +else +fprintf (f," fdir hash=%#x id=%#x " , m->hash.fdir.hash, m->hash.fdir.id); + } +fprintf (f,", ptype=%#" PRIx32"\n" , m->packet_type); nb_segs = m->nb_segs;
Signature · 1 line
2.45.2
PATCH v9 4/8 test: add test for packet dissector
In reply to Stephen HemmingerAdd some tests for new packet dissector.
--- app/test/meson.build | 1 + app/test/test_dissect.c | 302 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 303 insertions(+) create mode 100644 app/test/test_dissect.c
app/test/meson.build +1 -0
@@ -62,6 +62,7 @@ source_file_deps = { 'test_debug.c': [], 'test_devargs.c': ['kvargs'], 'test_dispatcher.c': ['dispatcher'], + 'test_dissect.c': ['net'], 'test_distributor.c': ['distributor'], 'test_distributor_perf.c': ['distributor'], 'test_dmadev.c': ['dmadev', 'bus_vdev'],
app/test/test_dissect.c new file +302 -0
302 lines not on this page · raw message
Signature · 1 line
2.45.2
PATCH v9 5/8 test-pmd: add option to redirect packet log
In reply to Stephen HemmingerWhen running tests in interactive mode, it is useful to be able to redirect the packet decode (verbose output) into a file.
--- app/test-pmd/cmdline.c | 41 +++++++++++++++++++++ app/test-pmd/config.c | 23 ++++++++++++ app/test-pmd/testpmd.c | 3 ++ app/test-pmd/testpmd.h | 3 ++ app/test-pmd/util.c | 11 +++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 ++++ 6 files changed, 86 insertions(+), 2 deletions(-)
app/test-pmd/cmdline.c +41 -0
@@ -302,6 +302,9 @@ static void cmd_help_long_parsed(void *parsed_result,"set verbose (level)\n" " Set the debug verbosity level X.\n\n" +"set output (filename)\n" +" Set the packet debug log file\n\n" +"set log global|(type) (level)\n" " Set the log level.\n\n"
@@ -3853,6 +3856,43 @@ static cmdline_parse_inst_t cmd_set_numbers = { }, }; + +/* *** SET OUTPUT FILENAME *** */ +struct cmd_set_output_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t output; +cmdline_fixed_string_t filename; +}; + +static void +cmd_set_output_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_output_result *res = parsed_result; + +set_output_file (res->filename); +} + +static cmdline_parse_token_string_t cmd_set_output_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_output_result, set, "set"); +static cmdline_parse_token_string_t cmd_set_output_output = + TOKEN_STRING_INITIALIZER(struct cmd_set_output_result, output, "output"); +static cmdline_parse_token_string_t cmd_set_output_name = + TOKEN_STRING_INITIALIZER(struct cmd_set_output_result, filename, NULL); + +static cmdline_parse_inst_t cmd_set_output = { + .f = cmd_set_output_parsed, + .data =NULL , + .help_str ="set output <filename>" , + .tokens = { + (void *)&cmd_set_output_set, + (void *)&cmd_set_output_output, + (void *)&cmd_set_output_name, +NULL , + }, +}; +/* *** SET LOG LEVEL CONFIGURATION *** */ struct cmd_set_log_result {
@@ -13166,6 +13206,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_reset, (cmdline_parse_inst_t *)&cmd_set_numbers, (cmdline_parse_inst_t *)&cmd_set_log, + (cmdline_parse_inst_t *)&cmd_set_output, (cmdline_parse_inst_t *)&cmd_set_rxoffs, (cmdline_parse_inst_t *)&cmd_set_rxpkts, (cmdline_parse_inst_t *)&cmd_set_rxhdrs,
app/test-pmd/config.c +23 -0
@@ -6268,6 +6268,29 @@ set_verbose_level(uint16_t vb_level)configure_rxtx_dump_callbacks (verbose_level); } +void +set_output_file (const char *filename) +{ +FILE *outf, *oldf; + +if (!strcmp (filename,"-" )) { + outf = stdout; + }else { + outf =fopen (filename,"a" ); +if (outf ==NULL ) { +perror (filename); +return ; + } + } + + oldf =rte_atomic_exchange_explicit (&output_file, outf, rte_memory_order_seq_cst); +if (oldf !=NULL && oldf != stdout) { +/* make sure other threads are not mid print */ +rte_delay_us_sleep (US_PER_S /10 ); +fclose (oldf); + } +} +void vlan_extend_set (portid_t port_id,int on) {
app/test-pmd/testpmd.c +3 -0
@@ -99,6 +99,7 @@#define EXTBUF_ZONE_SIZE (RTE_PGSIZE_2M - 4 * RTE_CACHE_LINE_SIZE)uint16_t verbose_level =0 ;/**< Silent by default. */ +RTE_ATOMIC (FILE *) output_file;/**< log to console by default. */ int testpmd_logtype;/**< Log type for testpmd logs */ /* use main core for command line ? */
@@ -4543,6 +4544,8 @@ main(int argc, char** argv)rte_exit (EXIT_FAILURE ,"Cannot register log type" );rte_log_set_level (testpmd_logtype,RTE_LOG_DEBUG ); + output_file = stdout; + diag =rte_eal_init (argc, argv);if (diag <0 ) rte_exit(EXIT_FAILURE, "Cannot init EAL: %s\n",
app/test-pmd/testpmd.h +3 -0
@@ -17,6 +17,7 @@#include <rte_ethdev.h> #include <rte_flow.h> #include <rte_mbuf_dyn.h> +#include <rte_stdatomic.h> #include <cmdline.h> #include <cmdline_parse.h>
@@ -493,6 +494,7 @@ extern uint8_t xstats_hide_zero; /**< Hide zero values for xstats display */extern uint8_t record_core_cycles;/**< Enables measurement of CPU cycles */ extern uint8_t record_burst_stats;/**< Enables display of RX and TX bursts */ extern uint16_t verbose_level;/**< Drives messages being displayed, if any. */ +extern RTE_ATOMIC (FILE *) output_file;/**< Where packet data is written */ extern int testpmd_logtype;/**< Log type for testpmd logs */ extern uint8_t interactive;extern uint8_t auto_start;
@@ -1102,6 +1104,7 @@ void set_xstats_hide_zero(uint8_t on_off);void set_record_core_cycles (uint8_t on_off);void set_record_burst_stats (uint8_t on_off);void set_verbose_level (uint16_t vb_level); +void set_output_file (const char *filename);void set_rx_pkt_segments (unsigned int *seg_lengths,unsigned int nb_segs);void set_rx_pkt_hdrs (unsigned int *seg_protos,unsigned int nb_segs);void show_rx_pkt_hdrs (void );
app/test-pmd/util.c +9 -2
@@ -89,9 +89,15 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],size_t buf_size =MAX_STRING_LEN ;size_t cur_len =0 ;uint64_t restore_info_dynflag; +FILE *outf;if (!nb_pkts)return ; + + outf =rte_atomic_load_explicit (&output_file, rte_memory_order_relaxed); +if (!outf) +return ; + restore_info_dynflag =rte_flow_restore_info_dynflag (); MKDUMPSTR(print_buf, buf_size, cur_len, "port %u/queue %u: %s %u packets\n", port_id, queue,
@@ -292,11 +298,12 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],MKDUMPSTR (print_buf, buf_size, cur_len,"INVALID mbuf: %s\n" , reason);if (cur_len >= buf_size) -printf ("%s ...\n" , print_buf); +fprintf (outf,"%s ...\n" , print_buf);else -printf ("%s" , print_buf); +fprintf (outf,"%s" , print_buf); cur_len =0 ; } +fflush (outf); }uint16_t
doc/guides/testpmd_app_ug/testpmd_funcs.rst +7 -0
@@ -665,6 +665,13 @@ Reset forwarding to the default configuration:: testpmd> set default +set output +~~~~~~~~~~ + +Redirect the debug log:: + + testpmd> set output /tmp/packet.log + set verbose ~~~~~~~~~~~
Signature · 1 line
2.45.2
PATCH v9 6/8 test-pmd: add hex decode
In reply to Stephen HemmingerThis adds new command:
testpmd> set format hex
which decodes packet in hex.
--- app/test-pmd/cmdline.c | 40 +++++++++++++++ app/test-pmd/config.c | 11 +++++ app/test-pmd/testpmd.c | 1 + app/test-pmd/testpmd.h | 7 +++ app/test-pmd/util.c | 54 ++++++++++++++++----- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 13 +++++ 6 files changed, 115 insertions(+), 11 deletions(-)
app/test-pmd/cmdline.c +40 -0
@@ -305,6 +305,9 @@ static void cmd_help_long_parsed(void *parsed_result,"set output (filename)\n" " Set the packet debug log file\n\n" +"set format (verbose|hex)\n" +" Set the format of packet log\\n" +"set log global|(type) (level)\n" " Set the log level.\n\n"
@@ -3893,6 +3896,42 @@ static cmdline_parse_inst_t cmd_set_output = { }, }; +/* *** SET FORMAT OF PACKET LOG */ +struct cmd_set_format_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t format; +cmdline_fixed_string_t value; +}; + +static void +cmd_set_format_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_format_result *res = parsed_result; + +set_output_format (res->value); +} + +static cmdline_parse_token_string_t cmd_set_format_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, set, "set"); +static cmdline_parse_token_string_t cmd_set_format_output = + TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, format, "format"); +static cmdline_parse_token_string_t cmd_set_format_value = + TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "verbose#hex"); + +static cmdline_parse_inst_t cmd_set_format = { + .f = cmd_set_format_parsed, + .data =NULL , + .help_str ="set format verbose|hex" , + .tokens = { + (void *)&cmd_set_format_set, + (void *)&cmd_set_format_output, + (void *)&cmd_set_format_value, +NULL , + }, +}; +/* *** SET LOG LEVEL CONFIGURATION *** */ struct cmd_set_log_result {
@@ -13207,6 +13246,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_numbers, (cmdline_parse_inst_t *)&cmd_set_log, (cmdline_parse_inst_t *)&cmd_set_output, + (cmdline_parse_inst_t *)&cmd_set_format, (cmdline_parse_inst_t *)&cmd_set_rxoffs, (cmdline_parse_inst_t *)&cmd_set_rxpkts, (cmdline_parse_inst_t *)&cmd_set_rxhdrs,
app/test-pmd/config.c +11 -0
@@ -6268,6 +6268,17 @@ set_verbose_level(uint16_t vb_level)configure_rxtx_dump_callbacks (verbose_level); } +void +set_output_format (const char *mode) +{ +if (!strcmp (mode,"verbose" )) + output_format =OUTPUT_MODE_VERBOSE ; +else if (!strcmp (mode,"hex" )) + output_format =OUTPUT_MODE_HEX ; +else +fprintf (stderr,"Unknown output format '%s'\n" , mode); +} +void set_output_file (const char *filename) {
app/test-pmd/testpmd.c +1 -0
@@ -100,6 +100,7 @@uint16_t verbose_level =0 ;/**< Silent by default. */ RTE_ATOMIC (FILE *) output_file;/**< log to console by default. */ +enum output_mode output_format;/**< default to original mode. */ int testpmd_logtype;/**< Log type for testpmd logs */ /* use main core for command line ? */
app/test-pmd/testpmd.h +7 -0
@@ -488,6 +488,11 @@ enum dcb_mode_enable DCB_ENABLED }; +enum output_mode { +OUTPUT_MODE_VERBOSE =0 , +OUTPUT_MODE_HEX , +}; +extern uint8_t xstats_hide_zero;/**< Hide zero values for xstats display */ /* globals used for configuration */
@@ -495,6 +500,7 @@ extern uint8_t record_core_cycles; /**< Enables measurement of CPU cycles */extern uint8_t record_burst_stats;/**< Enables display of RX and TX bursts */ extern uint16_t verbose_level;/**< Drives messages being displayed, if any. */ extern RTE_ATOMIC (FILE *) output_file;/**< Where packet data is written */ +extern enum output_mode output_format;/**< Format of packet decode */ extern int testpmd_logtype;/**< Log type for testpmd logs */ extern uint8_t interactive;extern uint8_t auto_start;
@@ -1104,6 +1110,7 @@ void set_xstats_hide_zero(uint8_t on_off);void set_record_core_cycles (uint8_t on_off);void set_record_burst_stats (uint8_t on_off);void set_verbose_level (uint16_t vb_level); +void set_output_format (const char *mode);void set_output_file (const char *filename);void set_rx_pkt_segments (unsigned int *seg_lengths,unsigned int nb_segs);void set_rx_pkt_hdrs (unsigned int *seg_protos,unsigned int nb_segs);
app/test-pmd/util.c +43 -11
78 lines not on this page · raw message
doc/guides/testpmd_app_ug/testpmd_funcs.rst +13 -0
@@ -672,6 +672,19 @@ Redirect the debug log:: testpmd> set output /tmp/packet.log +set format +~~~~~~~~~~ + +Chose the output format for packet debug log:: + + testpmd> set format verbose|hex + +Available formats are: + +* ``verbose`` print the packet meta data information +* ``hex`` print the mbuf flags and data in hex + + set verbose ~~~~~~~~~~~
Signature · 1 line
2.45.2
PATCH v9 7/8 test-pmd: add packet dissect format
In reply to Stephen HemmingerAdd ability to get decode packet in summary tshark style format.
--- app/test-pmd/cmdline.c | 6 ++-- app/test-pmd/config.c | 23 +++++++++---- app/test-pmd/testpmd.h | 1 + app/test-pmd/util.c | 36 +++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 3 +- 5 files changed, 59 insertions(+), 10 deletions(-)
app/test-pmd/cmdline.c +3 -3
@@ -305,7 +305,7 @@ static void cmd_help_long_parsed(void *parsed_result,"set output (filename)\n" " Set the packet debug log file\n\n" -"set format (verbose|hex)\n" +"set format (dissect|hex|verbose)\n" " Set the format of packet log\\n" "set log global|(type) (level)\n"
@@ -3918,12 +3918,12 @@ static cmdline_parse_token_string_t cmd_set_format_set =static cmdline_parse_token_string_t cmd_set_format_output = TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, format, "format");static cmdline_parse_token_string_t cmd_set_format_value = - TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "verbose#hex"); + TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "dissect#hex#verbose");static cmdline_parse_inst_t cmd_set_format = { .f = cmd_set_format_parsed, .data =NULL , - .help_str ="set format verbose|hex" , + .help_str ="set format dissect|hex|verbose" , .tokens = { (void *)&cmd_set_format_set, (void *)&cmd_set_format_output,
app/test-pmd/config.c +17 -6
@@ -6271,12 +6271,23 @@ set_verbose_level(uint16_t vb_level)void set_output_format (const char *mode) { -if (!strcmp (mode,"verbose" )) - output_format =OUTPUT_MODE_VERBOSE ; -else if (!strcmp (mode,"hex" )) - output_format =OUTPUT_MODE_HEX ; -else -fprintf (stderr,"Unknown output format '%s'\n" , mode); +static const char *const output_formats[] = { + [OUTPUT_MODE_VERBOSE ] ="verbose" , + [OUTPUT_MODE_HEX ] ="hex" , + [OUTPUT_MODE_DISSECT ] ="dissect" , + }; + +printf ("Change output format from %s to %s\n" , + output_formats[output_format], mode); + +for (unsigned int i =0 ; i <RTE_DIM (output_formats); i++) { +if (strcasecmp (mode, output_formats[i]) ==0 ) { + output_format = i; +return ; + } + } + +fprintf (stderr,"Unknown output format '%s'\n" , mode); }void
app/test-pmd/testpmd.h +1 -0
@@ -491,6 +491,7 @@ enum dcb_mode_enableenum output_mode {OUTPUT_MODE_VERBOSE =0 ,OUTPUT_MODE_HEX , +OUTPUT_MODE_DISSECT , };extern uint8_t xstats_hide_zero;/**< Hide zero values for xstats display */
app/test-pmd/util.c +36 -0
@@ -8,6 +8,7 @@#include <rte_bitops.h> #include <rte_net.h> #include <rte_mbuf.h> +#include <rte_dissect.h> #include <rte_ether.h> #include <rte_vxlan.h> #include <rte_ethdev.h>
@@ -311,6 +312,38 @@ dump_pkt_hex(FILE *outf, uint16_t port_id, uint16_t queue, } } +/* Brief tshark style one line output which is +* number time_delta Source Destination Protocol len info +*/ +static void +dump_pkt_brief (FILE *outf,uint16_t port,uint16_t queue, +struct rte_mbuf *pkts[],uint16_t nb_pkts,int is_rx) +{ +static uint64_t start_cycles; +static RTE_ATOMIC (uint64_t ) packet_count =1 ; +uint64_t now, count; +double interval; + +/* Compute time interval from the first packet received */ + now =rte_rdtsc (); +if (start_cycles ==0 ) { + start_cycles = now; +printf ("Seq# Time Port:Que R Description\n" ); + } + interval = (double )(now - start_cycles) / (double )rte_get_tsc_hz (); + +/* Packet counter needs to be thread safe */ + count =rte_atomic_fetch_add_explicit (&packet_count, nb_pkts, rte_memory_order_relaxed); + +for (uint16_t i =0 ; i < nb_pkts; i++) { +const struct rte_mbuf *mb = pkts[i]; +char str[256 ]; + +rte_dissect_mbuf (str,sizeof (str), mb,0 ); +fprintf (outf,"%6" PRIu64" %11.9f %4u:%-3u %c %s\n" , + count + i, interval, port, queue, is_rx ?'R' :'T' , str); + } +} static void dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
@@ -332,6 +365,9 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],case OUTPUT_MODE_HEX :dump_pkt_hex (outf, port_id, queue, pkts, nb_pkts, is_rx);break ; +case OUTPUT_MODE_DISSECT : +dump_pkt_brief (outf, port_id, queue, pkts, nb_pkts, is_rx); +break ;default :return ; }
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -1
@@ -677,12 +677,13 @@ set format Chose the output format for packet debug log:: - testpmd> set format verbose|hex + testpmd> set format dissect|hex|verbose Available formats are: * ``verbose`` print the packet meta data information * ``hex`` print the mbuf flags and data in hex +* ``dissect`` print the packet in tshark summary format set verbose
Signature · 1 line
2.45.2
PATCH v9 8/8 test-pmd: add a JSON packet output
In reply to Stephen HemmingerWhen doing automated testing it is useful to show packet meta data in JSON.
--- app/test-pmd/cmdline.c | 6 +- app/test-pmd/config.c | 3 + app/test-pmd/testpmd.h | 1 + app/test-pmd/util.c | 167 ++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +- 5 files changed, 178 insertions(+), 6 deletions(-)
app/test-pmd/cmdline.c +3 -3
@@ -305,7 +305,7 @@ static void cmd_help_long_parsed(void *parsed_result,"set output (filename)\n" " Set the packet debug log file\n\n" -"set format (dissect|hex|verbose)\n" +"set format (dissect|hex|json|verbose)\n" " Set the format of packet log\\n" "set log global|(type) (level)\n"
@@ -3918,12 +3918,12 @@ static cmdline_parse_token_string_t cmd_set_format_set =static cmdline_parse_token_string_t cmd_set_format_output = TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, format, "format");static cmdline_parse_token_string_t cmd_set_format_value = - TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "dissect#hex#verbose"); + TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "dissect#hex#json#verbose");static cmdline_parse_inst_t cmd_set_format = { .f = cmd_set_format_parsed, .data =NULL , - .help_str ="set format dissect|hex|verbose" , + .help_str ="set format dissect|hex|json|verbose" , .tokens = { (void *)&cmd_set_format_set, (void *)&cmd_set_format_output,
app/test-pmd/config.c +3 -0
@@ -6275,6 +6275,9 @@ set_output_format(const char *mode) [OUTPUT_MODE_VERBOSE] = "verbose", [OUTPUT_MODE_HEX] = "hex", [OUTPUT_MODE_DISSECT ] ="dissect" , +#ifdef RTE_HAS_JANSSON + [OUTPUT_MODE_JSON ] ="json" , +#endif }; printf("Change output format from %s to %s\n",
app/test-pmd/testpmd.h +1 -0
@@ -492,6 +492,7 @@ enum output_mode {OUTPUT_MODE_VERBOSE =0 ,OUTPUT_MODE_HEX ,OUTPUT_MODE_DISSECT , + OUTPUT_MODE_JSON, };extern uint8_t xstats_hide_zero;/**< Hide zero values for xstats display */
app/test-pmd/util.c +167 -0
179 lines not on this page · raw message
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -3
@@ -677,13 +677,14 @@ set format Chose the output format for packet debug log:: - testpmd> set format dissect|hex|verbose + testpmd> set format dissect|hex|json|verbose Available formats are: -* ``verbose`` print the packet meta data information -* ``hex`` print the mbuf flags and data in hex * ``dissect`` print the packet in tshark summary format +* ``hex`` print the mbuf flags and data in hex +* ``json`` print the packet meta data in json +* ``verbose`` print the packet meta data information set verbose
Signature · 1 line
2.45.2
v10 cover test-pmd packet decoding enhancements
In reply to Stephen HemmingerWhile debugging TAP rte_flow discovered that test pmd verbose output was confusing and unhelpful. Instead, made a simple dissector that prints one line per packet like this in test-pmd.
Also supports hex and JSON mode when more detail is needed.
The new commands are:
testpmd> set output /tmp/packet.log
testpmd> set format dissect
To enable packet logging need to use:
testpmd> set verbose 3
v10 - rebase based on changes to lib/net and cmdline
Stephen Hemminger (8):
net: add more icmp types
net: add new packet dissector
mbuf: decode the hash and fdir info in rte_pktmbuf_dump
test: add test for packet dissector
test-pmd: add option to redirect packet log
test-pmd: add hex decode
test-pmd: add packet dissect format
test-pmd: add a JSON packet output
app/test-pmd/cmdline.c | 81 ++++ app/test-pmd/config.c | 48 +++ app/test-pmd/testpmd.c | 4 + app/test-pmd/testpmd.h | 12 + app/test-pmd/util.c | 256 +++++++++++- app/test/meson.build | 1 + app/test/test_dissect.c | 302 ++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 22 + lib/mbuf/rte_mbuf.c | 14 + lib/net/meson.build | 2 + lib/net/rte_dissect.c | 429 ++++++++++++++++++++ lib/net/rte_dissect.h | 45 ++ lib/net/rte_icmp.h | 9 + lib/net/version.map | 7 + 14 files changed, 1225 insertions(+), 7 deletions(-) create mode 100644 app/test/test_dissect.c create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
Signature · 1 line
2.45.2
PATCH v10 1/8 net: add more icmp types
Add types for SOURCE_QUENCH and IPv6 neighbor discovery.
--- lib/net/rte_icmp.h | 9 +++++++++ 1 file changed, 9 insertions(+)
lib/net/rte_icmp.h +9 -0
@@ -54,6 +54,7 @@ struct rte_icmp_hdr {#define RTE_IP_ICMP_ECHO_REPLY \ (RTE_DEPRECATED(RTE_IP_ICMP_ECHO_REPLY) RTE_ICMP_TYPE_ECHO_REPLY)#define RTE_ICMP_TYPE_DEST_UNREACHABLE 3 +#define RTE_ICMP_TYPE_SOURCE_QUENCH 4#define RTE_ICMP_TYPE_REDIRECT 5#define RTE_ICMP_TYPE_ECHO_REQUEST 8#define RTE_IP_ICMP_ECHO_REQUEST \
@@ -62,6 +63,8 @@ struct rte_icmp_hdr {#define RTE_ICMP_TYPE_PARAM_PROBLEM 12#define RTE_ICMP_TYPE_TIMESTAMP_REQUEST 13#define RTE_ICMP_TYPE_TIMESTAMP_REPLY 14 +#define RTE_ICMP_TYPE_INFO_REQUEST 15 +#define RTE_ICMP_TYPE_INFO_REPLY 16/* Destination Unreachable codes */ #define RTE_ICMP_CODE_UNREACH_NET 0
@@ -84,4 +87,10 @@ struct rte_icmp_hdr {#define RTE_ICMP6_ECHO_REQUEST 128#define RTE_ICMP6_ECHO_REPLY 129 +/* Neighbor discovery */ +#define RTE_ND_ROUTER_SOLICIT 133 +#define RTE_ND_ROUTER_ADVERT 134 +#define RTE_ND_NEIGHBOR_SOLICIT 135 +#define RTE_ND_NEIGHBOR_ADVERT 136 +#endif /* RTE_ICMP_H_ */
Signature · 1 line
2.45.2
PATCH v10 2/8 net: add new packet dissector
In reply to Stephen HemmingerThe function rte_dissect_mbuf is used to decode the contents of an mbuf into ah uman readable format similar to what tshark uses.
For now, handles IP, IPv6, TCP, UDP, ICMP and ARP.
--- lib/net/meson.build | 2 + lib/net/rte_dissect.c | 429 ++++++++++++++++++++++++++++++++++++++++++ lib/net/rte_dissect.h | 45 +++++ lib/net/version.map | 7 + 4 files changed, 483 insertions(+) create mode 100644 lib/net/rte_dissect.c create mode 100644 lib/net/rte_dissect.h
lib/net/meson.build +2 -0
@@ -3,6 +3,7 @@ headers = files( 'rte_cksum.h', + 'rte_dissect.h', 'rte_ip.h', 'rte_ip4.h', 'rte_ip6.h',
@@ -33,6 +34,7 @@ headers = files( sources = files( 'rte_arp.c', + 'rte_dissect.c', 'rte_ether.c', 'rte_net.c', 'rte_net_crc.c',
lib/net/rte_dissect.c new file +429 -0
429 lines not on this page · raw message
lib/net/rte_dissect.h new file +45 -0
45 lines not on this page · raw message
lib/net/version.map +7 -0
@@ -12,3 +12,10 @@ DPDK_25 { local: *; }; + +EXPERIMENTAL { + global: + + # added in 24.11 + rte_dissect_mbuf; +};
Signature · 1 line
2.45.2
PATCH v10 3/8 mbuf: decode the hash and fdir info in rte_pktmbuf_dump
In reply to Stephen HemmingerUseful to be able to see the meta data in the hex dump.
--- lib/mbuf/rte_mbuf.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
lib/mbuf/rte_mbuf.c +14 -0
@@ -678,12 +678,26 @@ rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len)fprintf (f," pkt_len=%u, ol_flags=%#" PRIx64", nb_segs=%u, port=%u" , m->pkt_len, m->ol_flags, m->nb_segs, m->port); +if (m->port !=RTE_MBUF_PORT_INVALID ) +fprintf (f,", port=%u" , m->port); +if (m->ol_flags & (RTE_MBUF_F_RX_QINQ |RTE_MBUF_F_TX_QINQ ))fprintf (f,", vlan_tci_outer=%u" , m->vlan_tci_outer);if (m->ol_flags & (RTE_MBUF_F_RX_VLAN |RTE_MBUF_F_TX_VLAN ))fprintf (f,", vlan_tci=%u" , m->vlan_tci); +if (m->ol_flags &RTE_MBUF_F_RX_RSS_HASH ) +fprintf (f,", rss=%#x" , m->hash.rss); +else if (m->ol_flags &RTE_MBUF_F_RX_FDIR ) { +if (m->ol_flags &RTE_MBUF_F_RX_FDIR_ID ) +fprintf (f,", fdir id=%u" , m->hash.fdir.id); +else if (m->ol_flags &RTE_MBUF_F_RX_FDIR_FLX ) +fprintf (f,", fdir flex=%#x %x" , m->hash.fdir.hi, m->hash.fdir.lo); +else +fprintf (f," fdir hash=%#x id=%#x " , m->hash.fdir.hash, m->hash.fdir.id); + } +fprintf (f,", ptype=%#" PRIx32"\n" , m->packet_type); nb_segs = m->nb_segs;
Signature · 1 line
2.45.2
PATCH v10 4/8 test: add test for packet dissector
In reply to Stephen HemmingerAdd some tests for new packet dissector.
--- app/test/meson.build | 1 + app/test/test_dissect.c | 302 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 303 insertions(+) create mode 100644 app/test/test_dissect.c
app/test/meson.build +1 -0
@@ -63,6 +63,7 @@ source_file_deps = { 'test_debug.c': [], 'test_devargs.c': ['kvargs'], 'test_dispatcher.c': ['dispatcher'], + 'test_dissect.c': ['net'], 'test_distributor.c': ['distributor'], 'test_distributor_perf.c': ['distributor'], 'test_dmadev.c': ['dmadev', 'bus_vdev'],
app/test/test_dissect.c new file +302 -0
302 lines not on this page · raw message
Signature · 1 line
2.45.2
PATCH v10 5/8 test-pmd: add option to redirect packet log
In reply to Stephen HemmingerWhen running tests in interactive mode, it is useful to be able to redirect the packet decode (verbose output) into a file.
--- app/test-pmd/cmdline.c | 41 +++++++++++++++++++++ app/test-pmd/config.c | 23 ++++++++++++ app/test-pmd/testpmd.c | 3 ++ app/test-pmd/testpmd.h | 3 ++ app/test-pmd/util.c | 11 +++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 ++++ 6 files changed, 86 insertions(+), 2 deletions(-)
app/test-pmd/cmdline.c +41 -0
@@ -315,6 +315,9 @@ static void cmd_help_long_parsed(void *parsed_result,"set verbose (level)\n" " Set the debug verbosity level X.\n\n" +"set output (filename)\n" +" Set the packet debug log file\n\n" +"set log global|(type) (level)\n" " Set the log level.\n\n"
@@ -4110,6 +4113,43 @@ static cmdline_parse_inst_t cmd_set_numbers = { }, }; + +/* *** SET OUTPUT FILENAME *** */ +struct cmd_set_output_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t output; +cmdline_fixed_string_t filename; +}; + +static void +cmd_set_output_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_output_result *res = parsed_result; + +set_output_file (res->filename); +} + +static cmdline_parse_token_string_t cmd_set_output_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_output_result, set, "set"); +static cmdline_parse_token_string_t cmd_set_output_output = + TOKEN_STRING_INITIALIZER(struct cmd_set_output_result, output, "output"); +static cmdline_parse_token_string_t cmd_set_output_name = + TOKEN_STRING_INITIALIZER(struct cmd_set_output_result, filename, NULL); + +static cmdline_parse_inst_t cmd_set_output = { + .f = cmd_set_output_parsed, + .data =NULL , + .help_str ="set output <filename>" , + .tokens = { + (void *)&cmd_set_output_set, + (void *)&cmd_set_output_output, + (void *)&cmd_set_output_name, +NULL , + }, +}; +/* *** SET LOG LEVEL CONFIGURATION *** */ struct cmd_set_log_result {
@@ -13650,6 +13690,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { &cmd_set_xstats_hide_zero, &cmd_set_record_core_cycles, &cmd_set_record_burst_stats, + &cmd_set_output, &cmd_operate_port, &cmd_operate_specific_port, &cmd_operate_attach_port,
app/test-pmd/config.c +23 -0
@@ -6340,6 +6340,29 @@ set_verbose_level(uint16_t vb_level)configure_rxtx_dump_callbacks (verbose_level); } +void +set_output_file (const char *filename) +{ +FILE *outf, *oldf; + +if (!strcmp (filename,"-" )) { + outf = stdout; + }else { + outf =fopen (filename,"a" ); +if (outf ==NULL ) { +perror (filename); +return ; + } + } + + oldf =rte_atomic_exchange_explicit (&output_file, outf, rte_memory_order_seq_cst); +if (oldf !=NULL && oldf != stdout) { +/* make sure other threads are not mid print */ +rte_delay_us_sleep (US_PER_S /10 ); +fclose (oldf); + } +} +void vlan_extend_set (portid_t port_id,int on) {
app/test-pmd/testpmd.c +3 -0
@@ -99,6 +99,7 @@#define EXTBUF_ZONE_SIZE (RTE_PGSIZE_2M - 4 * RTE_CACHE_LINE_SIZE)uint16_t verbose_level =0 ;/**< Silent by default. */ +RTE_ATOMIC (FILE *) output_file;/**< log to console by default. */ int testpmd_logtype;/**< Log type for testpmd logs */ /* use main core for command line ? */
@@ -4543,6 +4544,8 @@ main(int argc, char** argv)rte_exit (EXIT_FAILURE ,"Cannot register log type" );rte_log_set_level (testpmd_logtype,RTE_LOG_DEBUG ); + output_file = stdout; + diag =rte_eal_init (argc, argv);if (diag <0 ) rte_exit(EXIT_FAILURE, "Cannot init EAL: %s\n",
app/test-pmd/testpmd.h +3 -0
@@ -17,6 +17,7 @@#include <rte_ethdev.h> #include <rte_flow.h> #include <rte_mbuf_dyn.h> +#include <rte_stdatomic.h> #include <cmdline.h> #include <cmdline_parse.h>
@@ -493,6 +494,7 @@ extern uint8_t xstats_hide_zero; /**< Hide zero values for xstats display */extern uint8_t record_core_cycles;/**< Enables measurement of CPU cycles */ extern uint8_t record_burst_stats;/**< Enables display of RX and TX bursts */ extern uint16_t verbose_level;/**< Drives messages being displayed, if any. */ +extern RTE_ATOMIC (FILE *) output_file;/**< Where packet data is written */ extern int testpmd_logtype;/**< Log type for testpmd logs */ extern uint8_t interactive;extern uint8_t auto_start;
@@ -1105,6 +1107,7 @@ void set_xstats_hide_zero(uint8_t on_off);void set_record_core_cycles (uint8_t on_off);void set_record_burst_stats (uint8_t on_off);void set_verbose_level (uint16_t vb_level); +void set_output_file (const char *filename);void set_rx_pkt_segments (unsigned int *seg_lengths,unsigned int nb_segs);void set_rx_pkt_hdrs (unsigned int *seg_protos,unsigned int nb_segs);void show_rx_pkt_hdrs (void );
app/test-pmd/util.c +9 -2
@@ -89,9 +89,15 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],size_t buf_size =MAX_STRING_LEN ;size_t cur_len =0 ;uint64_t restore_info_dynflag; +FILE *outf;if (!nb_pkts)return ; + + outf =rte_atomic_load_explicit (&output_file, rte_memory_order_relaxed); +if (!outf) +return ; + restore_info_dynflag =rte_flow_restore_info_dynflag (); MKDUMPSTR(print_buf, buf_size, cur_len, "port %u/queue %u: %s %u packets\n", port_id, queue,
@@ -292,11 +298,12 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],MKDUMPSTR (print_buf, buf_size, cur_len,"INVALID mbuf: %s\n" , reason);if (cur_len >= buf_size) -printf ("%s ...\n" , print_buf); +fprintf (outf,"%s ...\n" , print_buf);else -printf ("%s" , print_buf); +fprintf (outf,"%s" , print_buf); cur_len =0 ; } +fflush (outf); }uint16_t
doc/guides/testpmd_app_ug/testpmd_funcs.rst +7 -0
@@ -684,6 +684,13 @@ Reset forwarding to the default configuration:: testpmd> set default +set output +~~~~~~~~~~ + +Redirect the debug log:: + + testpmd> set output /tmp/packet.log + set verbose ~~~~~~~~~~~
Signature · 1 line
2.45.2
PATCH v10 6/8 test-pmd: add hex decode
In reply to Stephen HemmingerThis adds new command:
testpmd> set format hex
which decodes packet in hex.
--- app/test-pmd/cmdline.c | 40 +++++++++++++++ app/test-pmd/config.c | 11 +++++ app/test-pmd/testpmd.c | 1 + app/test-pmd/testpmd.h | 7 +++ app/test-pmd/util.c | 54 ++++++++++++++++----- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 13 +++++ 6 files changed, 115 insertions(+), 11 deletions(-)
app/test-pmd/cmdline.c +40 -0
@@ -318,6 +318,9 @@ static void cmd_help_long_parsed(void *parsed_result,"set output (filename)\n" " Set the packet debug log file\n\n" +"set format (verbose|hex)\n" +" Set the format of packet log\\n" +"set log global|(type) (level)\n" " Set the log level.\n\n"
@@ -4150,6 +4153,42 @@ static cmdline_parse_inst_t cmd_set_output = { }, }; +/* *** SET FORMAT OF PACKET LOG */ +struct cmd_set_format_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t format; +cmdline_fixed_string_t value; +}; + +static void +cmd_set_format_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_format_result *res = parsed_result; + +set_output_format (res->value); +} + +static cmdline_parse_token_string_t cmd_set_format_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, set, "set"); +static cmdline_parse_token_string_t cmd_set_format_output = + TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, format, "format"); +static cmdline_parse_token_string_t cmd_set_format_value = + TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "verbose#hex"); + +static cmdline_parse_inst_t cmd_set_format = { + .f = cmd_set_format_parsed, + .data =NULL , + .help_str ="set format verbose|hex" , + .tokens = { + (void *)&cmd_set_format_set, + (void *)&cmd_set_format_output, + (void *)&cmd_set_format_value, +NULL , + }, +}; +/* *** SET LOG LEVEL CONFIGURATION *** */ struct cmd_set_log_result {
@@ -13685,6 +13724,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { &cmd_read_rxd_txd, &cmd_stop, &cmd_mac_addr, + &cmd_set_format, &cmd_set_fwd_eth_peer, &cmd_set_qmap, &cmd_set_xstats_hide_zero,
app/test-pmd/config.c +11 -0
@@ -6340,6 +6340,17 @@ set_verbose_level(uint16_t vb_level)configure_rxtx_dump_callbacks (verbose_level); } +void +set_output_format (const char *mode) +{ +if (!strcmp (mode,"verbose" )) + output_format =OUTPUT_MODE_VERBOSE ; +else if (!strcmp (mode,"hex" )) + output_format =OUTPUT_MODE_HEX ; +else +fprintf (stderr,"Unknown output format '%s'\n" , mode); +} +void set_output_file (const char *filename) {
app/test-pmd/testpmd.c +1 -0
@@ -100,6 +100,7 @@uint16_t verbose_level =0 ;/**< Silent by default. */ RTE_ATOMIC (FILE *) output_file;/**< log to console by default. */ +enum output_mode output_format;/**< default to original mode. */ int testpmd_logtype;/**< Log type for testpmd logs */ /* use main core for command line ? */
app/test-pmd/testpmd.h +7 -0
@@ -488,6 +488,11 @@ enum dcb_mode_enable DCB_ENABLED }; +enum output_mode { +OUTPUT_MODE_VERBOSE =0 , +OUTPUT_MODE_HEX , +}; +extern uint8_t xstats_hide_zero;/**< Hide zero values for xstats display */ /* globals used for configuration */
@@ -495,6 +500,7 @@ extern uint8_t record_core_cycles; /**< Enables measurement of CPU cycles */extern uint8_t record_burst_stats;/**< Enables display of RX and TX bursts */ extern uint16_t verbose_level;/**< Drives messages being displayed, if any. */ extern RTE_ATOMIC (FILE *) output_file;/**< Where packet data is written */ +extern enum output_mode output_format;/**< Format of packet decode */ extern int testpmd_logtype;/**< Log type for testpmd logs */ extern uint8_t interactive;extern uint8_t auto_start;
@@ -1107,6 +1113,7 @@ void set_xstats_hide_zero(uint8_t on_off);void set_record_core_cycles (uint8_t on_off);void set_record_burst_stats (uint8_t on_off);void set_verbose_level (uint16_t vb_level); +void set_output_format (const char *mode);void set_output_file (const char *filename);void set_rx_pkt_segments (unsigned int *seg_lengths,unsigned int nb_segs);void set_rx_pkt_hdrs (unsigned int *seg_protos,unsigned int nb_segs);
app/test-pmd/util.c +43 -11
78 lines not on this page · raw message
doc/guides/testpmd_app_ug/testpmd_funcs.rst +13 -0
@@ -691,6 +691,19 @@ Redirect the debug log:: testpmd> set output /tmp/packet.log +set format +~~~~~~~~~~ + +Chose the output format for packet debug log:: + + testpmd> set format verbose|hex + +Available formats are: + +* ``verbose`` print the packet meta data information +* ``hex`` print the mbuf flags and data in hex + + set verbose ~~~~~~~~~~~
Signature · 1 line
2.45.2
PATCH v10 7/8 test-pmd: add packet dissect format
In reply to Stephen HemmingerAdd ability to get decode packet in summary tshark style format.
--- app/test-pmd/cmdline.c | 6 ++-- app/test-pmd/config.c | 23 +++++++++---- app/test-pmd/testpmd.h | 1 + app/test-pmd/util.c | 36 +++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 3 +- 5 files changed, 59 insertions(+), 10 deletions(-)
app/test-pmd/cmdline.c +3 -3
@@ -318,7 +318,7 @@ static void cmd_help_long_parsed(void *parsed_result,"set output (filename)\n" " Set the packet debug log file\n\n" -"set format (verbose|hex)\n" +"set format (dissect|hex|verbose)\n" " Set the format of packet log\\n" "set log global|(type) (level)\n"
@@ -4175,12 +4175,12 @@ static cmdline_parse_token_string_t cmd_set_format_set =static cmdline_parse_token_string_t cmd_set_format_output = TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, format, "format");static cmdline_parse_token_string_t cmd_set_format_value = - TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "verbose#hex"); + TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "dissect#hex#verbose");static cmdline_parse_inst_t cmd_set_format = { .f = cmd_set_format_parsed, .data =NULL , - .help_str ="set format verbose|hex" , + .help_str ="set format dissect|hex|verbose" , .tokens = { (void *)&cmd_set_format_set, (void *)&cmd_set_format_output,
app/test-pmd/config.c +17 -6
@@ -6343,12 +6343,23 @@ set_verbose_level(uint16_t vb_level)void set_output_format (const char *mode) { -if (!strcmp (mode,"verbose" )) - output_format =OUTPUT_MODE_VERBOSE ; -else if (!strcmp (mode,"hex" )) - output_format =OUTPUT_MODE_HEX ; -else -fprintf (stderr,"Unknown output format '%s'\n" , mode); +static const char *const output_formats[] = { + [OUTPUT_MODE_VERBOSE ] ="verbose" , + [OUTPUT_MODE_HEX ] ="hex" , + [OUTPUT_MODE_DISSECT ] ="dissect" , + }; + +printf ("Change output format from %s to %s\n" , + output_formats[output_format], mode); + +for (unsigned int i =0 ; i <RTE_DIM (output_formats); i++) { +if (strcasecmp (mode, output_formats[i]) ==0 ) { + output_format = i; +return ; + } + } + +fprintf (stderr,"Unknown output format '%s'\n" , mode); }void
app/test-pmd/testpmd.h +1 -0
@@ -491,6 +491,7 @@ enum dcb_mode_enableenum output_mode {OUTPUT_MODE_VERBOSE =0 ,OUTPUT_MODE_HEX , +OUTPUT_MODE_DISSECT , };extern uint8_t xstats_hide_zero;/**< Hide zero values for xstats display */
app/test-pmd/util.c +36 -0
@@ -8,6 +8,7 @@#include <rte_bitops.h> #include <rte_net.h> #include <rte_mbuf.h> +#include <rte_dissect.h> #include <rte_ether.h> #include <rte_vxlan.h> #include <rte_ethdev.h>
@@ -311,6 +312,38 @@ dump_pkt_hex(FILE *outf, uint16_t port_id, uint16_t queue, } } +/* Brief tshark style one line output which is +* number time_delta Source Destination Protocol len info +*/ +static void +dump_pkt_brief (FILE *outf,uint16_t port,uint16_t queue, +struct rte_mbuf *pkts[],uint16_t nb_pkts,int is_rx) +{ +static uint64_t start_cycles; +static RTE_ATOMIC (uint64_t ) packet_count =1 ; +uint64_t now, count; +double interval; + +/* Compute time interval from the first packet received */ + now =rte_rdtsc (); +if (start_cycles ==0 ) { + start_cycles = now; +printf ("Seq# Time Port:Que R Description\n" ); + } + interval = (double )(now - start_cycles) / (double )rte_get_tsc_hz (); + +/* Packet counter needs to be thread safe */ + count =rte_atomic_fetch_add_explicit (&packet_count, nb_pkts, rte_memory_order_relaxed); + +for (uint16_t i =0 ; i < nb_pkts; i++) { +const struct rte_mbuf *mb = pkts[i]; +char str[256 ]; + +rte_dissect_mbuf (str,sizeof (str), mb,0 ); +fprintf (outf,"%6" PRIu64" %11.9f %4u:%-3u %c %s\n" , + count + i, interval, port, queue, is_rx ?'R' :'T' , str); + } +} static void dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
@@ -332,6 +365,9 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],case OUTPUT_MODE_HEX :dump_pkt_hex (outf, port_id, queue, pkts, nb_pkts, is_rx);break ; +case OUTPUT_MODE_DISSECT : +dump_pkt_brief (outf, port_id, queue, pkts, nb_pkts, is_rx); +break ;default :return ; }
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -1
@@ -696,12 +696,13 @@ set format Chose the output format for packet debug log:: - testpmd> set format verbose|hex + testpmd> set format dissect|hex|verbose Available formats are: * ``verbose`` print the packet meta data information * ``hex`` print the mbuf flags and data in hex +* ``dissect`` print the packet in tshark summary format set verbose
Signature · 1 line
2.45.2
PATCH v10 8/8 test-pmd: add a JSON packet output
In reply to Stephen HemmingerWhen doing automated testing it is useful to show packet meta data in JSON.
--- app/test-pmd/cmdline.c | 6 +- app/test-pmd/config.c | 3 + app/test-pmd/testpmd.h | 1 + app/test-pmd/util.c | 167 ++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +- 5 files changed, 178 insertions(+), 6 deletions(-)
app/test-pmd/cmdline.c +3 -3
@@ -318,7 +318,7 @@ static void cmd_help_long_parsed(void *parsed_result,"set output (filename)\n" " Set the packet debug log file\n\n" -"set format (dissect|hex|verbose)\n" +"set format (dissect|hex|json|verbose)\n" " Set the format of packet log\\n" "set log global|(type) (level)\n"
@@ -4175,12 +4175,12 @@ static cmdline_parse_token_string_t cmd_set_format_set =static cmdline_parse_token_string_t cmd_set_format_output = TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, format, "format");static cmdline_parse_token_string_t cmd_set_format_value = - TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "dissect#hex#verbose"); + TOKEN_STRING_INITIALIZER(struct cmd_set_format_result, value, "dissect#hex#json#verbose");static cmdline_parse_inst_t cmd_set_format = { .f = cmd_set_format_parsed, .data =NULL , - .help_str ="set format dissect|hex|verbose" , + .help_str ="set format dissect|hex|json|verbose" , .tokens = { (void *)&cmd_set_format_set, (void *)&cmd_set_format_output,
app/test-pmd/config.c +3 -0
@@ -6347,6 +6347,9 @@ set_output_format(const char *mode) [OUTPUT_MODE_VERBOSE] = "verbose", [OUTPUT_MODE_HEX] = "hex", [OUTPUT_MODE_DISSECT ] ="dissect" , +#ifdef RTE_HAS_JANSSON + [OUTPUT_MODE_JSON ] ="json" , +#endif }; printf("Change output format from %s to %s\n",
app/test-pmd/testpmd.h +1 -0
@@ -492,6 +492,7 @@ enum output_mode {OUTPUT_MODE_VERBOSE =0 ,OUTPUT_MODE_HEX ,OUTPUT_MODE_DISSECT , + OUTPUT_MODE_JSON, };extern uint8_t xstats_hide_zero;/**< Hide zero values for xstats display */
app/test-pmd/util.c +167 -0
179 lines not on this page · raw message
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -3
@@ -696,13 +696,14 @@ set format Chose the output format for packet debug log:: - testpmd> set format dissect|hex|verbose + testpmd> set format dissect|hex|json|verbose Available formats are: -* ``verbose`` print the packet meta data information -* ``hex`` print the mbuf flags and data in hex * ``dissect`` print the packet in tshark summary format +* ``hex`` print the mbuf flags and data in hex +* ``json`` print the packet meta data in json +* ``verbose`` print the packet meta data information set verbose
Signature · 1 line
2.45.2